MySQL Access denied for user root@localhost 解决方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL Access denied for user root@localhost 解决方法相关的知识,希望对你有一定的参考价值。

今天把本地开发的项目(Thinkphp 3.2.3)移到虚拟机上(CentOS 6.6,LNMP 1.2,mysql 5.6.23),配置好 MySQL 之后访问首页,出现:

技术分享

 

此时 MySQL 的用户名和密码都是 root

解决方法是:

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(newpassword) where USER=root;
mysql> FLUSH PRIVILEGES;
mysql> quit

重新启动 LNMP。

 

参考:

mysql Access denied for user [email protected]错误解决方法总结

以上是关于MySQL Access denied for user root@localhost 解决方法的主要内容,如果未能解决你的问题,请参考以下文章

java访问数据库被拒绝,不能连接数据库ERROR 1045 (28000): Access denied for user 'root'@'localhost' (u

ERROR 1045 (28000): Access denied for user 'root'@'localhost'

mysql错误 Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES)

mariadb mysql -u root -p 显示Access denied解决办法

MySql access denied for user错误

Mysql Access denied for user 'root'