赞
踩
购买云服务器后,选择了带MySQL环境的镜像,查看日志知道初始密码是空,但是使用’mysql -u root --skip-password’ 无法登陆数据库。
官方参考:2.10.4 Securing the Initial MySQL Account
# 查看MySQL安装日志
root@VM-0-16-ubuntu:/data# head /var/log/mysql/error.log|grep -E 'root' --color=auto
2020-02-29T14:35:51.914062Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
操作环境:Ubuntu 18.04 + MySQL 8.0.19
命令摘要:
mysqld --user=mysql --skip-grant-tables
mysql
mysql> flush privileges;
mysql> alter user 'root'@'localhost' identified by '123456';
详细步骤:
root@VM-0-16-ubuntu:/data# mysqld --user=mysql --skip-grant-tables
启动成功后的日志信息(ready for connections):
root@VM-0-16-ubuntu:/data# tail -f /var/log/mysql/error.log
2020-05-25T11:13:00.156006Z 0 [System] [MY-010931]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。