解决mysql“Access denied for user 'root'@&_MySQL
程序员文章站
2022-05-16 09:25:17
...
解决mysql“Access denied for user 'root'@'localhost'”
我的系统是ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):
方法一:
# /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
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password:
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
Enter password:
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password:
mysql>
方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!!
# mysql -uroot -p
Enter password:
至此,困惑多时的问题解决了!
来源:
来自为知笔记(Wiz)
上一篇: LVS+Mysql集群负载均衡
推荐阅读
-
win10下MySQL 8.0登录Access denied for user‘root’@‘localhost’ (using password: YES)问题的解决方法
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决
-
MySQL密码正确却无法本地登录-1045 Access denied for user 'root'@'localhost' (using password:YES
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法
-
解决mysql创建数据库后出现:Access denied for user 'root'@'%' to database 'xxx'的问题
-
提示:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'的错误如何解决?
-
Access denied for user 'root'@'localhost' (using password:YES) Mysql5.7
-
转载--MYSQL5.7:Access denied for user 'root'@'localhost' (using pa
-
mysql登录错误:'Access denied for user 'root'@'localhost'