mysql “Access denied for user 'root'@'localhost'

# mysql -uroot -p

Enter password:

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

解决方法:
# /etc/init.d/mysqld stop  \\停止mysql
# mysqld_safe --user=mysql --skip-grant-tables & \\以后台模式启动mysql服务
然后以重新以root用户登录就可以了
 
 
note:--skip-grant-tablels
该选项使服务器不使用权限系统。该权限允许访问服务器的用户不受限制地访问所有数据库。你可以从系统外壳命令行执行mysqladmin flush-privilegesmysqladmin reload命令,或执行MySQL FLUSH PRIVILEGES语句让运行的服务器重新开始使用 授权表。
原文地址:https://www.cnblogs.com/un4sure/p/2215091.html