1,初始化环境
useradd mysql
mkdir /3333
mkdir /3333/data
mkdir /3333/log
mkdir /3333/run
touch /3333/log/db.log
chown -R mysql:mysql /3333
2,初始化数据库,无密码
[root@db01 data]# /opt/mysql/bin/mysqld --datadir=/3333/data --user=mysql --initialize-insecure
-02-07T02:12:02.462057Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
-02-07T02:12:02.773084Z 0 [Warning] InnoDB: New log files created, LSN=45790
-02-07T02:12:02.825583Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
-02-07T02:12:02.887143Z 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: de29a256-68e9-11eb-b2ef-000c29a91aed.
-02-07T02:12:02.887685Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
-02-07T02:12:02.888181Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
3,初始化数据库
cat >> /3333/data/f<
[mysqld]
port=3333
datadir=/3333/data
socket=/3333/mysql.sock
[mysqld_safe]
log-error=/3333/log/db.log
pid-file=/3333/run/db.pid
EOF
4,设置开机自动启动脚本
[root@db01 support-files]# pwd
/opt/mysql/support-files
[root@db01 support-files]# cp mysql.server mysql3333
[root@db01 support-files]# chmod +x mysql3333
support-files 文件设置开机启动脚本:
1,datadir=/3333/data
2,lockdir='/3333'
3,启动参数文件f,放到datadir目录(extra_args="-e $datadir/f)