Initialize Secure
cd /opt/app/mysql
# 酌情调整监听地址,InnoDB Buffer Poll 大小等配置
vim 3306/etc/my.cnf
# 初始化
./bin/mysqld --defaults-file=3306/etc/my.cnf --initialize
# 启动服务
systemctl start 2345-mysql-3306
# 查看初始化密码
grep 'temporary password' 3306/logs/error_mysqld.log
# 登录 MySQL
./bin/mysql --defaults-file=3306/etc/my.cnf -uroot
ALTER USER IF EXISTS 'root'@'localhost' IDENTIFIED BY '{PASSWD}'
不提倡的非安全初始化
Initialize Insecure
cd /opt/app/mysql
# 酌情调整监听地址,InnoDB Buffer Poll 大小等配置
vim 3306/etc/my.cnf
# 初始化
./bin/mysqld --defaults-file=./3306/etc/my.cnf --initialize-insecure
# 启动服务
systemctl start 2345-mysql-3306
# 登录 MySQL
./bin/mysql --defaults-file=3306/etc/my.cnf -uroot