[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3306
2022-07-29T05:48:04.206397Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-29T05:48:04.369296Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-29T05:48:04.403256Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-29T05:48:04.462960Z 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: 03b0e61e-0f02-11ed-b4ce-000c296d5362.
2022-07-29T05:48:04.464340Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-29T05:48:04.643259Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T05:48:04.643284Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T05:48:04.643585Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-29T05:48:04.717924Z 1 [Note] A temporary password is generated for root@localhost: ,dASzpwwE3RJ
[root@localhost ~]# echo ',dASzpwwE3RJ' > 3306
[root@localhost ~]# ls
3306 anaconda-ks.cfg
//初始化3307
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3307
2022-07-29T05:49:29.037700Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-29T05:49:29.195218Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-29T05:49:29.224130Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-29T05:49:29.281903Z 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: 363f3e1c-0f02-11ed-8fdd-000c296d5362.
2022-07-29T05:49:29.283175Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-29T05:49:29.523082Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T05:49:29.523118Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T05:49:29.523503Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-29T05:49:29.581009Z 1 [Note] A temporary password is generated for root@localhost: )MhldlF<o23j
[root@localhost ~]# echo ')MhldlF<o23j' > 3307
[root@localhost ~]# ls
3306 3307 anaconda-ks.cfg
//初始化3308
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3308
2022-07-29T05:50:14.735254Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-29T05:50:14.892190Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-29T05:50:14.915269Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-29T05:50:14.973272Z 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: 517b3121-0f02-11ed-a3f6-000c296d5362.
2022-07-29T05:50:14.974697Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-29T05:50:15.340479Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T05:50:15.340510Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T05:50:15.341068Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-29T05:50:15.368072Z 1 [Note] A temporary password is generated for root@localhost: tkdnhiEk>5vh
[root@localhost ~]# echo 'tkdnhiEk>5vh' > 3308
[root@localhost ~]# ls
3306 3307 3308 anaconda-ks.cfg
复制代码
5.配置配置文件/etc/my.cnf
[root@localhost ~]# vim /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
[mysqld3306]
datadir = /opt/data/3306
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /opt/data/3306/mysql_3306.pid
log-error=/var/log/3306.log
[mysqld3307]
datadir = /opt/data/3307
port = 3307
socket = /tmp/mysql3307.sock
pid-file = /opt/data/3307/mysql_3307.pid
log-error=/var/log/3307.log
[mysqld3308]
datadir = /opt/data/3308
port = 3308
socket = /tmp/mysql3308.sock
pid-file = /opt/data/3308/mysql_3308.pid
log-error=/var/log/3308.log
复制代码
6.启动各示例
[root@localhost ~]# mysqld_multi start 3306
-bash: /usr/local/mysql/bin/mysqld_multi: /usr/bin/perl: bad interpreter: No such file or directory //需要下载perl包