curl -L -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.23-el7-x86_64.tar
[root]# rpm -qa|grep mysql[root]# rpm -qa |grep mariadb-libs
yum remove mariadb-libs -y
tar -xvf mysql-8.0.23-el7-x86_64.tar
[root]# groupadd mysql[root]# useradd -r -g mysql -s /bin/false mysql [root]# cd /usr/local/
[root local]# tar xzvf /root/mysql-8.0.23-el7-x86_64.tar.gz
sudo ln -s /usr/local/mysql-8.0.23-el7-x86_64/ mysql
mkdir -p /mysql/{3306,3307,3308,3309}/data
chown -R mysql:mysql /mysql
cd /mysql
Example 1 (3306)
[mysqld] port = 3306basedir=/usr/local/mysql/
datadir=/mysql/3306/data
lower_case_table_names=1
innodb_buffer_pool_size=128M
socket=/tmp/mysql_3306.sock
log_error=/mysql/3306/data/mysql06.log
Example 2 (3307)
[mysqld] port = 3307basedir=/usr/local/mysql/
datadir=/mysql/3307/data
lower_case_table_names=1
innodb_buffer_pool_size=128M
socket=/tmp/mysql_3307.sock
log_error=/mysql/3307/data/mysql07.log
Example 3 (3308)
[mysqld] port = 3308basedir=/usr/local/mysql/
datadir=/mysql/3308/data
lower_case_table_names=1
innodb_buffer_pool_size=128M
socket=/tmp/mysql_3308.sock
log_error=/mysql/3308/data/mysql08.log
3306
/usr/local/mysql/bin/mysqld –defaults-file=/mysql/3306/my.cnf –initialize –basedir=/usr/local/mysql/ –datadir=/mysql/3306/data
3307
/usr/local/mysql/bin/mysqld –defaults-file=/mysql/3307/my.cnf –initialize –basedir=/usr/local/mysql/ –datadir=/mysql/3307/data
3308
/usr/local/mysql/bin/mysqld –defaults-file=/mysql/3308/my.cnf –initialize –basedir=/usr/local/mysql/ –datadir=/mysql/3308/data
ln -s /usr/local/mysql/bin/mysqld /usr/bin
[root]# vi /etc/profileor vi .bash_profile
# Add the following information at the end of the file
export PATH=$PATH:/usr/local/mysql/bin
#Make environment variables take effect
[root]# source /etc/profile
# After testing, some of the file permissions newly generated by mysql during initialization are root, so it is best to re-authorize the datadir path to mysql before starting
chown -R mysql:mysql /mysql
nohup /usr/local/mysql/bin/mysqld –defaults-file=/mysql/3306/my.cnf –user=mysql &
nohup /usr/local/mysql/bin/mysqld –defaults-file=/mysql/3307/my.cnf –user=mysql &
nohup /usr/local/mysql/bin/mysqld –defaults-file=/mysql/3308/my.cnf –user=mysql &
ps -ef| grep mysql
netstat -ntl
#Change password for all instance one by one:
mysql -S /tmp/mysql_3306.sock -p
#enter temp password from log:
alter user ‘root’@’localhost’ identified by ‘Not_so_secure1!’;
to shutdown an instance
[root@localhost bin]# pwd
/usr/local/mysql/bin
[root@localhost bin]# ./mysqladmin -h127.0.0.1 -uroot -p -P3306 shutdown
Enter password:
root@localhost bin]# ps -ef| grep mysql
mysql 22218 21246 0 11:56 pts/1 00:00:03 /usr/local/mysql/bin/mysqld –defaults-file=/mysql/3307/my.cnf –user=mysql
mysql 22259 21246 0 11:56 pts/1 00:00:03 /usr/local/mysql/bin/mysqld –defaults-file=/mysql/3308/my.cnf –user=mysql
root 22673 21537 0 12:24 pts/2 00:00:00 mysql -S /tmp/mysql_3306.sock -p
root 22705 21537 0 12:26 pts/2 00:00:00 grep –color=auto mysql