MySQL 8.0 设置初始密码

安装好mysql 8.0后,查看初始密码:

sudo grep 'temporary password' /var/log/mysqld.log

本地MySQL客户端登录:mysql -uroot -p ,输入默认密码进去,如果不修改默认密码,操作执行命令会报错如下:

You must reset your password using ALTER USER statement before executing this statement.

修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '*{your-password}*';