一、准备
~]# useradd MysqL
二、安装
先安装MysqL5.6
1.解压,并改名
~]# tar xfMysqL-5.6.40-linux-glibc2.12-x86_64.tar.gz -C /opt
~]# cd /opt
~]# mvMysqL-5.6.40-linux-glibc2.12-x86_64 MysqL56
2.初始化MysqL
~]# cd MysqL56
~]#./scripts/MysqL_install_db --user=MysqL --datadir=/opt/MysqL56/data --basedir=/opt/MysqL56
注:如果在安装的过程中出现
解决方法是安装autoconf库
执行命令:yum -y install autoconf
安装完成之后继续执行安装MysqL的命令
这时候会在MysqL中自动创建一个文件my.cng,编辑这个文件
[MysqLd] basedir=/opt/MysqL56 datadir=/opt/MysqL56/data port=3316 socket=/opt/MysqL56/MysqL.sock explicit_defaults_for_timestamp=true sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
3.运行启动MysqL56
~]#./bin/MysqLd_safe --defaults-file=/opt/MysqL56/my.cnf --user=root &
接下来安装MysqL5.7
1.解压,并改名
~]# tar xfMysqL-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /opt
~]# cd /opt
~]# mvMysqL-5.7.22-linux-glibc2.12-x86_64 MysqL57
2.编辑my.cnf
~]# vim /etc/my.cnf
[client] port=3326 default-character-set=utf8 socket=/opt/MysqL57/MysqL.sock [MysqL] port=3326 socket=/opt/MysqL57/MysqL.sock [MysqLd] bind-address=0.0.0.0 log_error=/opt/MysqL57/log/MysqLd_error.log slow_query_log_file=/opt/MysqL57/log/MysqLd_slow.log general_log_file=/opt/MysqL57/log/MysqLd_gener.log basedir=/opt/MysqL57 datadir=/opt/MysqL57/data port=3326 socket=/opt/MysqL57/MysqL.sock explicit_defaults_for_timestamp=true tmpdir=/opt/MysqL57 pid-file=/opt/MysqL57/MysqLd.pid
~]# mkdir data log
~]# bin/MysqLd --initialize --user=MysqL --basedir=/opt/MysqL57 --datadir=/opt/MysqL57/data
~]#cat log/MysqLd_error.log
~]#mv /etc/my.cnf ./
~]#bin/MysqLd_safe --defaults-file=/opt/MysqL57/my.cnf --user=root &