卸载旧版本
rpm -qa | grep mysql rpm -e --nodeps mysql
下载MySQL 5.6.14
cd /usr/local/src wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.31.tar.gz tar -zxvf mysql-5.6.31.tar.gz cd mysql-5.6.31
准备
#安装编译代码需要的包 yum -y install make gcc-c++ cmake bison-devel ncurses-devel #添加用户和组 groupadd -r mysql useradd -s /sbin/nologin -g mysql -r mysql id mysql
编译
rm -f CMakeCache.txt mv /etc/my.cnf /etc/my.cnf.bak cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/mysql-5.6.31 \ -DMYSQL_DATADIR=/usr/local/mysql/mysql-5.6.31/data \ -DSYSCONFDIR=/usr/local/mysql/mysql-5.6.31/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql-5.6.31/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci
make && make install
编译参数
http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html配置
mkdir -p /usr/local/mysql/mysql-5.6.31
chown -R mysql:mysql /usr/local/mysql/mysql-5.6.31
cd /usr/local/mysql/mysql-5.6.31
yum -y install autoconf
mkdir logs
scripts/mysql_install_db --defaults-file=/usr/local/mysql/mysql-5.6.31/my.cnf.bak
显示
To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/mysql-5.6.31//bin/mysqladmin -u root password ‘new-password’
/usr/local/mysql/mysql-5.6.31//bin/mysqladmin -u root -h webserver password ‘new-password’
Alternatively you can run:
/usr/local/mysql/mysql-5.6.31//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/mysql-5.6.31//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file ./my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as ./my-new.cnf,
please compare it with your file and take the changes you need.
设置开机启动
vim /etc/rc.local /usr/local/mysql/mysql-5.6.31/bin/mysqld_safe --defaults-file=/usr/local/mysql/mysql-5.6.31/my.cnf &检查
启动mysql
/usr/local/mysql/mysql-5.6.31/bin/mysqld_safe --defaults-file=/usr/local/mysql/mysql-5.6.31/my.cnf & ps aux|grep mysql /usr/local/mysql/mysql-5.6.31/bin/mysqladmin -u root password 'new-password' show VARIABLES like '%character%';
关闭mysql
/usr/local/mysql/mysql-5.6.31/bin/mysqladmin shutdown -u root -p
需改root密码 授权
use mysql; UPDATE user SET Password = PASSWORD('123456') WHERE user = 'root'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' identified by "123456" WITH GRANT OPTION; FLUSH PRIVILEGES;