你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu下MySQL的'Access denied for user 'root'@'localhost' (using password: YES)'错误

[日期:2013-11-15] 来源:Linux社区  作者:Linux [字体:大 中 小]

问题现象:
我的环境是xUbuntu 12.10下apt-get安装mysql,登陆无法登陆,报错信息这样描述:在用命令(sudo apt-get install mysql-server mysql-client)安装完.mysql服务即开始运行了.此时需要修改root密码,但经常会出现这么一种情况.'Access denied for user 'root'@'localhost' (using password: YES)' 或者其他致使无法登录mysql的情况。

解决方法:
1.打开/etc/mysql/debian.cnf文件,里面存储了相关的密码,我的文件信息如下

sudovi /etc/mysql/debian.cnf# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock

[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

在[client]段有user=以及password=这两行,这就是通过apt-get安装mysql,系统给我们设置的mysql登录名和密码

2. 输入命令:
mysql -udebian-sys-maint -pdebian-sys- maint即debian.cnf中user=后面的内容.回车后会提示输入密码,此时把password=后面的内容复制粘贴后回车即可进行mysql 控制台


3.进入控制台后.按以下步骤进行:
use mysql;update user set password=PASSWORD('新密码') where user='root';FLUSH PRIVILEGES;此时可以输入quit;退出后用root帐号登录,也可以继续其他操作.

相关阅读:

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql  http://www.linuxidc.com/Linux/2013-03/81341.htm  与 http://www.linuxidc.com/Linux/2012-06/63618.htm

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)  http://www.linuxidc.com/Linux/2012-11/74518.htm

MySQL无lock tables权限 报Access denied for user when using LOCK TABLES  http://www.linuxidc.com/Linux/2012-01/51802.htm

gentoo下运行mysql提示Access denied for user 'root'@'localhost'错误的解决  http://www.linuxidc.com/Linux/2007-12/9866.htm

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

linux
相关资讯       MySQL错误 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款