cd /usr/Environment/Mysql/mysql-5.7.30 ./bin/mysqld --initialize --user=mysql --basedir=/usr/Environment/Mysql/mysql-5.7.30/ --datadir=/usr/Environment/Mysql/mysql-5.7.30/data/
14.初始化完成后查看日志中的临时密码
1 2
cd data/ cat mysqld.log
临时密码为:i>;+lyB5Ojon
1 2 3 4 5 6 7
2020-08-07T07:37:17.198965Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-08-07T07:37:17.594529Z 0 [Warning] InnoDB: New log files created, LSN=45790 2020-08-07T07:37:17.700675Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2020-08-07T07:37:17.769067Z 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: d1ee4afd-d880-11ea-8942-a0c589328791. 2020-08-07T07:37:17.772722Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2020-08-07T07:37:19.446295Z 0 [Warning] CA certificate ca.pem is self signed. 2020-08-07T07:37:19.783441Z 1 [Note] A temporary password is generated for root@localhost: i>;+lyB5Ojon
15.把启动脚本放到开机初始化目录
1 2
cd /usr/Environment/Mysql/mysql-5.7.30/support-files/ cp mysql.server /etc/init.d/mysql
16.编辑 /etc/init.d/mysql 文件
1
vim /etc/init.d/mysql
将文件中的basedir、datadir赋值为上面配置的目录即可
17.配置环境变量
1 2 3 4 5 6
vim /etc/profile #环境变量下面增加以下两行,目录根据个人不同进行修改 #目的是可以在任意目录下启动 mysql 服务与登录 mysql export MYSQLBIN_HOME=/usr/Environment/Mysql/mysql-5.7.30 export PATH=$MYSQLBIN_HOME/bin:$PATH