[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
--2022-07-31 12:25:27-- https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
Resolving downloads.mysql.com (downloads.mysql.com)... 23.2.135.207, 2600:140b:2:99c::2e31, 2600:140b:2:99d::2e31
Connecting to downloads.mysql.com (downloads.mysql.com)|23.2.135.207|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz [following]
--2022-07-31 12:25:28-- https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
Resolving cdn.mysql.com (cdn.mysql.com)... 23.78.91.208
Connecting to cdn.mysql.com (cdn.mysql.com)|23.78.91.208|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 674830866 (644M) [application/x-tar-gz]
Saving to: 'mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz'
mysql-5.7.38-linux-glibc 100%[===============================>] 643.57M 1.33MB/s in 11m 18s
2022-07-31 12:36:47 (971 KB/s) - 'mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz' saved [674830866/674830866]
[root@localhost src]# ls
debug kernels mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
2.配置用户&组,解压二进制程序
[root@localhost src]# useradd -M -r -s /sbin/nologin mysql
[root@localhost src]# id mysql
uid=994(mysql) gid=991(mysql) groups=991(mysql)
[root@localhost src]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# cd
[root@localhost ~]# ls /usr/local/
bin games lib libexec sbin src
etc include lib64 mysql-5.7.38-linux-glibc2.12-x86_64 share
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -sv mysql-5.7.38-linux-glibc2.12-x86_64 mysql
'mysql' -> 'mysql-5.7.38-linux-glibc2.12-x86_64'
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 6 Jun 22 2021 bin
drwxr-xr-x. 2 root root 6 Jun 22 2021 etc
drwxr-xr-x. 2 root root 6 Jun 22 2021 games
drwxr-xr-x. 2 root root 6 Jun 22 2021 include
drwxr-xr-x. 2 root root 6 Jun 22 2021 lib
drwxr-xr-x. 3 root root 17 Jul 19 14:22 lib64
drwxr-xr-x. 2 root root 6 Jun 22 2021 libexec
lrwxrwxrwx. 1 root root 35 Jul 31 13:20 mysql -> mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 9 root root 129 Jul 31 13:18 mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 Jun 22 2021 sbin
drwxr-xr-x. 5 root root 49 Jul 19 14:22 share
drwxr-xr-x. 2 root root 6 Jun 22 2021 src
//修改目录/usr/local/mysql的属主属组
[root@localhost local]# chown -R mysql.mysql mysql*
[root@localhost local]# ll /usr/local/mysql -d
lrwxrwxrwx. 1 mysql mysql 35 Jul 31 13:20 /usr/local/mysql -> mysql-5.7.38-linux-glibc2.12-x86_64
//配置环境变量
[root@localhost local]# echo 'export PATH=$PATH:/usr/local/mysql/bin' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/profile.d/mysql.sh
[root@localhost local]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
//创建头文件
[root@localhost local]# cd /usr/local/mysql
[root@localhost mysql]# ls
LICENSE README bin docs include lib man share support-files
[root@localhost mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
'/usr/include/mysql' -> '/usr/local/mysql/include/'
[root@localhost mysql]# chown -R mysql.mysql /usr/include/mysql
[root@localhost mysql]# ll -d /usr/include/mysql
lrwxrwxrwx. 1 mysql mysql 25 Jul 31 13:25 /usr/include/mysql -> /usr/local/mysql/include/
[root@localhost ~]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib/
[root@localhost ~]# ldconfig
[root@localhost ~]# vim /etc/man_db.conf
#MANDATORY_MANPATH /usr/src/pvm3/man
#
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/mysql/man //在前一行后面添加此行
3.创建各实例数据存放的目录
[root@localhost ~]# mkdir -p /opt/data/{3306,3307,3308}
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll /opt/data/
total 0
drwxr-xr-x. 2 mysql mysql 6 Jul 31 13:30 3306
drwxr-xr-x. 2 mysql mysql 6 Jul 31 13:30 3307
drwxr-xr-x. 2 mysql mysql 6 Jul 31 13:30 3308
[root@localhost ~]# tree /opt/data/
/opt/data/
|-- 3306
|-- 3307
`-- 3308
3 directories, 0 files
4.初始化示例
//3306:
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3306
2022-07-31T05:33:50.861240Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T05:33:51.136267Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T05:33:51.232923Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T05:33:51.246349Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5bf5e024-1092-11ed-aa1a-000c2939ef7e.
2022-07-31T05:33:51.247152Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T05:33:51.439341Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T05:33:51.439384Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T05:33:51.439731Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T05:33:51.569766Z 1 [Note] A temporary password is generated for root@localhost: J1gfquM7TO-L
[root@localhost ~]# echo 'J1gfquM7TO-L' > 3306
[root@localhost ~]# ls
3306 anaconda-ks.cfg
//3307:
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3307
2022-07-31T05:35:56.454739Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T05:35:56.950322Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T05:35:57.055888Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T05:35:57.069465Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a6f4f5b2-1092-11ed-b570-000c2939ef7e.
2022-07-31T05:35:57.071681Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T05:35:57.215920Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T05:35:57.215972Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T05:35:57.216383Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T05:35:57.244414Z 1 [Note] A temporary password is generated for root@localhost: DRquWwW1mW!&
[root@localhost ~]# echo 'DRquWwW1mW!&' > 3307
[root@localhost ~]# ls
3306 3307 anaconda-ks.cfg
//3308:
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3308
2022-07-31T05:37:20.519694Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T05:37:21.052193Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T05:37:21.152296Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T05:37:21.164130Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d914c986-1092-11ed-a72f-000c2939ef7e.
2022-07-31T05:37:21.165048Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T05:37:21.521412Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T05:37:21.521472Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T05:37:21.521857Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T05:37:21.647704Z 1 [Note] A temporary password is generated for root@localhost: fsHA=urhD4-r
[root@localhost ~]# echo 'fsHA=urhD4-r' >3308
[root@localhost ~]# ls
3306 3307 3308 anaconda-ks.cfg
[root@localhost ~]# mysqld_multi start 3306
-bash: /usr/local/mysql/bin/mysqld_multi: /usr/bin/perl: bad interpreter: No such file or directory
[root@localhost ~]# dnf -y install perl
[root@localhost mysql]# yum install ncurses-compat-libs
[root@localhost ~]# file /usr/local/mysql/bin/mysqld_multi
/usr/local/mysql/bin/mysqld_multi: Perl script text executable
[root@localhost ~]# mysqld_multi start 3306
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_CN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
[root@localhost ~]# mysqld_multi start 3307
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_CN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
[root@localhost ~]# mysqld_multi start 3308
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_CN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
[root@localhost ~]# ss -amlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:*
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0,d0)
LISTEN 0 80 *:opsession-prxy *:*
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0,d0)
LISTEN 0 80 *:tns-server *:*
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0,d0)
LISTEN 0 128 [::]:ssh [::]:*
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0,d0)
LISTEN 0 80 *:mysql *:*
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0,d0)