mysql 源码安装

1.  今天准备对mysql进行分区,但是数据库的mysql的版本是5.0.9靠,没办法只能卸载后重新安装。

2.  先卸载,说实话我不知道卸载的完全不,方法:直接把bin目录下的mysql文件干掉,然后把mysql的目录干掉。马马虎虎算卸载了

3.  开始安装:参考:http://www.57cto.com/thread-2913-1-1.html

安装软件包
# mkdir -p /opt/mysql
# mv mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz /opt/mysql
# cd /opt/mysql
# tar xvfz mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz

创建数据库
# cd /opt
# cd /opt/mysql/mysql-5.6.17-linux-glibc2.5-x86_64
# scripts/mysql_install_db --user=mysql

创建实例目录
# mkdir -p /opt/mysql/server0/log
# mkdir -p /opt/mysql/server0/run
# cp -R data /opt/mysql/server0
# cp my.cnf /opt/mysql/server0

配置启动参数
# cd /opt/mysql/server0
# vi my.cnf
[mysqld_safe]
basedir=/opt/mysql/mysql-5.6.17-linux-glibc2.5-x86_64
datadir=/opt/mysql/server0/data
log-error=/opt/mysql/server0/log/error.log
socket=/tmp/mysql_server0.sock
# cd /opt
# chmod -R mysql:dba mysql

启动mysql
$ export $MYSQL_BASE=/opt/mysql/mysql-5.6.17-linux-glibc2.5-x86_64
$ $MYSQL_BASE/bin/mysqld_safe --defaults-files=/opt/mysql/server0/my.cnf --ledir=$MYSQL_BASE/bin --user=mysql

这里贴出来我的my.cnf文件:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[client]
default-character-set = utf8

[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci

key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 
[mysqld_safe]
basedir=/usr/local/mysql5.6/mysql-5.6.17-linux-glibc2.5-x86_64
datadir=/usr/local/mysql5.6/mysql-5.6.17-linux-glibc2.5-x86_64/server0/data
log-error=/usr/local/mysql5.6/mysql-5.6.17-linux-glibc2.5-x86_64/server0/log/error.log
#socket=/tmp/mysql.sock
socket=/var/lib/mysql/mysql.sock

innodb_file_per_table=1
4.  在进入mysql客户端的时候会出现这种错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决方案:

解决方案<一>:在my.cnf文件中配置成:socket=/var/lib/mysql/mysql.sock

解决方案<二>:ln -s/tmp/mysql .sock  /var/lib/mysql/mysql .sock   

参考:http://www.cnblogs.com/super-lucky/p/superlucky.html

5.  在用safe去启动的时候,一定要注意加上绝对路径

bin/mysqld_safe --defaults-file=/usr/local/mysql5.6/mysql-5.6.17-linux-glibc2.5-x86_64/server0/my.cnf

注意:这样启动的时候你推出命令行后,过一段时间mysql会自动停止服务,

解决方案:nohup bin/mysqld_safe --defaults-file=/usr/local/mysql5.6/mysql-5.6.17-linux-glibc2.5-x86_64/server0/my.cnf  &

6.  kill 结束mysqld

ps -ef | grep mysql

kill - 9 ...

给一个mysql镜像的地址:ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/


7.  增大tomcat内存的方法

http://blog.csdn.net/ye1992/article/details/14517527

    

8.  备份mysql

mysqldump -uroot -p654123 -S /var/lib/mysql/mysql.sock -B plannex | gzip > /home/data/backup/mysqlbak_$(date +%F).sql.gz

9. 给数据库授权

grant all on *.* to 'username'@'%' identified by '123'

你可能感兴趣的:(mysql 源码安装)