mysql5.6 多实例标准化安装
1.检查防火墙 是否关闭
service iptables stop
chkconfig iptables off
service iptables status
2. SELINUX
vim /etc/selinux/config
SELINUX=disabled
3.配置yum源
4.
yum install -y cmake gcc gcc-c++ ncurses-devel bison zlib libxml
yum install -y openssl-devel
yum install -y lrzsz
5.
groupadd mysql
useradd -d /home/mysql -g mysql -m mysql
6.
su - mysql
vi .bash_profile
PATH=$PATH:$HOME/bin:/u01/svr/mysql/bin
7.
mkdir -p /u01/svr/mysql5.5
mkdir -p /u01/svr/mysql5.6
mkdir -p /u01/svr/mysql5.7
mkdir -p /u01/svr/mysql8.0
mkdir -p /u01/svr/configfile
mkdir -p /u01/svr/scripts
mkdir -p /u01/svr/backups
mkdir -p /u01/svr/install_files
mkdir -p /u01/svr/data/my3306
mkdir -p /u01/svr/log/my3306/iblog
mkdir -p /u01/svr/log/my3306/binlog
mkdir -p /u01/svr/working/my3306/temp
mkdir -p /u01/svr/working/my3306/run
mkdir -p /u01/svr/data/my3307
mkdir -p /u01/svr/log/my3307/iblog
mkdir -p /u01/svr/log/my3307/binlog
mkdir -p /u01/svr/working/my3307/temp
mkdir -p /u01/svr/working/my3307/run
mkdir -p /u01/svr/data/my3308
mkdir -p /u01/svr/log/my3308/iblog
mkdir -p /u01/svr/log/my3308/binlog
mkdir -p /u01/svr/working/my3308/temp
mkdir -p /u01/svr/working/my3308/run
mkdir -p /u01/svr/data/my3309
mkdir -p /u01/svr/log/my3309/iblog
mkdir -p /u01/svr/log/my3309/binlog
mkdir -p /u01/svr/working/my3309/temp
mkdir -p /u01/svr/working/my3309/run
8.
ln -s /u01/svr/mysql5.6 /u01/svr/mysql
9.
rz /u01/svr/install_files/mysql-5.6.43.tar.gz
tar -zxvf mysql-5.6.43.tar.gz
cd /u01/svr/install_files/mysql-5.6.43
10.预编译
cmake \
-DCMAKE_INSTALL_PREFIX=/u01/svr/mysql \
-DINSTALL_DATADIR=/u01/svr/data/my3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_SSL=yes \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/u01/svr/working/my3306/run/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DSYSCONFDIR=/etc \
-DWITH_READLINE=on
Configuring incomplete, errors occurred!
删除txt
find / -name CMakeCache.txt
rm -f /root/mysql/mysql-5.6.12/CMakeCache.txt
11.
make
make install
12.上传参数文件
cd /u01/svr
rz configfile
13.上传启动关闭连接脚本
cd /u01/svr
rz scripts
14.
chown -R mysql:mysql /u01/svr
chmod -R 755 /u01/svr
15.
su - mysql
cd /u01/svr/mysql
会根据my.cnf参数文件中执行的信息初始化数据库
./scripts/mysql_install_db --defaults-file=/u01/svr/configfile/my3306.cnf --datadir=/u01/svr/data/my3306 --user=mysql
./scripts/mysql_install_db --defaults-file=/u01/svr/configfile/my3307.cnf --datadir=/u01/svr/data/my3307 --user=mysql
./scripts/mysql_install_db --defaults-file=/u01/svr/configfile/my3308.cnf --datadir=/u01/svr/data/my3308 --user=mysql
./scripts/mysql_install_db --defaults-file=/u01/svr/configfile/my3309.cnf --datadir=/u01/svr/data/my3309 --user=mysql
16.启动mysql
su - mysql
mysqld_safe --defaults-file=/u01/svr/configfile/my3306.cnf --user=mysql &
mysqld_safe --defaults-file=/u01/svr/configfile/my3307.cnf --user=mysql &
mysqld_safe --defaults-file=/u01/svr/configfile/my3308.cnf --user=mysql &
mysqld_safe --defaults-file=/u01/svr/configfile/my3309.cnf --user=mysql &
17.连接数据库
mysql -h127.0.0.1 -uroot
mysql -h127.0.0.1 -uroot -P3306
大写P端口
小写p密码
18.升级数据库
tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar
su - mysql
ln -s mysql5.7 mysql
su - root
./mysql_upgrade --force -S /u01/svr/working/my3306/run/mysql.sock
./mysql_upgrade --force -S /u01/svr/working/my3307/run/mysql.sock
./mysql_upgrade --force -S /u01/svr/working/my3308/run/mysql.sock
./mysql_upgrade --force -S /u01/svr/working/my3309/run/mysql.sock
重启数据库完成升级