环境:
mysql:5.7
问题:
安装完mysql后使用mysql -uroot -p 登陆提示
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决方案:
百度一下都是千遍一律的说话,还是在Oracle 的官方文档中找到了答案
A superuser account 'root'@'localhost
is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
shell> sudo grep 'temporary password' /var/log/mysqld.log
原来安装mysql的时候系统自动创建了root账号的临时密码
[root@bogon ~]# sudo grep 'temporary password' /var/log/mysqld.log
2017-06-09T10:20:16.551437Z 1 [Note] A temporary password is generated for root@localhost: yLsi%4Zh1f(t