mysql安装启动 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
首次安装mysql 启动 mysql -uroot 以下错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决方案:
vim /etc/my.cnf
在[mysqld] 部分添加以下一行。
skip-grant-tables
重启mysql服务
systemctl restart mysqld.service
修改mysql密码
mysql> update user set authentication_string = password("XX@123") where user='root'; Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1
退出mysql, 把之前/etc/my.cnf文件中skip-grant-tables 注释掉。
重启mysql服务
进入mysql服务
mysql> SET PASSWORD = PASSWORD('XX@123'); Query OK, 0 rows affected, 1 warning (0.01 sec)