背景:现有mysql版本为5.5.40,考虑到以后需做主从,而5.6在主从方面、mysql读写方面都有很大提升。所以,准备升级。
官网:http://www.mysql.com/
环境:centos6.5 X86_64
安装目录:/database/mysql
解压目录:/database/mysql-5-6-24
数据存放目录:/database/sqldata
1、安装依赖包
yum install gcc gcc-c++ -y
yum install -y ncurses-devel
yum install -y openssl-devel(不安装会报错,见后文)
yum install -y cmake
yum install -y libaio
yum install -y bison
2、创建mysql用户用户组
groupadd mysql
useradd -g mysql mysql
3、cmake编译
tar –zxvf mysql-5.6.24.tar.gz
cd mysql-5-6-24cmake -DCMAKE_INSTALL_PREFIX:PATH=/database/mysql -DMYSQL_DATADIR:PATH=/database/sqldata -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DMYSQL_USER=mysql -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=yes
报错:CMake Error at cmake/ssl.cmake:83 (MESSAGE):
Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to
enable SSL support
Call Stack (most recent call first):
CMakeLists.txt:255 (MYSQL_CHECK_SSL)
解决:安装openssl-devel,然后rm CMakeCache.txt。重新运行以上命令。
make && make install
次步时间比较长。#添加PATH
echo "PATH=$PATH:/database/mysql/bin" >> /etc/profile
source /etc/profile#修改目录权限
chown -R mysql:mysql /database/mysql
chown -R mysql:mysql /database/sqldata
#拷贝配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf#设置my.conf 在[mysqld]中设置
datadir=/database/sqldata
#初始化
scripts/mysql_install_db --user=mysql --datadir=/database/sqldata --basedir=/database/mysql
日志:
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:
/db1/mysql/bin/mysqladmin -u root password ‘new-password‘
/db1/mysql/bin/mysqladmin -u root -h shekou password ‘new-password‘
Alternatively you can run:
/db1/mysql/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 . ; /db1/mysql/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 /db1/mysql/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 /db1/mysql/my-new.cnf,
please compare it with your file and take the changes you need.#设置mysql服务
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
service mysql start#空密码登陆mysql
mysql
4、mysql优化及其他操作(详见其他文章)
原文:http://strongit.blog.51cto.com/10020534/1775494