安装目录:/usr/local/mysql5.6
数据库目录 : /data/mysql/data
mysql安装包:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz
添加用户: useadd -s /sbin/nologin mysql
建立所需目录:
mkdir -p /data/mysql/data
chown -R mysql:mysql /data/mysql
安装编译mysql所需的程序或文件:
yum install gcc gcc-c++ cmake ncurses-devel bison
下载mysql源码包
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz
进行编译安装:
cd 进入根目录
解压源码包到当前目录:tar xzvf mysql-5.6.23.tar.gz
cd mysql-5.6.23
设置安装参数:
cmake -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6 -DINSTALL_DATADIR=/data/mysql/data -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock - DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
上面设置没问题接着到下一步编译:
make(编译过程需要耐心等待)
make install
编译完成,接下来设置一些参数文件
chown -R mysql:mysql /usr/local/mysql5.6
mv /usr/local/mysql5.6/support-files/my-default.cnf /etc/my.cnf(有旧配置文件则覆盖)
mv /usr/local/mysql5.6/support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
开始启动
chkconfig --level 345 mysqld on
设置环境变量
echo "export PATH=/usr/local/mysql5.6/bin/:$PATH" >> /etc/profile
source /etc/profile
设置完成查看是否写进了/etc/profile文件
/usr/local/mysql5.6/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql5.6 --datadir=/data/mysql/data
vim /etc/my.cnf
在配置文件写入参数:
basedir=/usr/local/mysql5.5
datadir=/data/mysql/data
重启mysqld
service mysqld reload
service mysqld restart
最后设置数据库管理员的登录密码:
/usr/local/mysql5.6/bin/mysqladmin -u root password ‘123456‘
设置完成进入mysql
mysql -uroot -p123456