求教:Access denied for user 'root'@'localhost' (using password: YES)

bjguikai 2010-09-02 02:13:45
装了mysql后,不知道什么时候执行了一次mysqladmin...的命令,
再连接数据库就出现了这种问题了:
Access denied for user 'root'@'localhost' (using password: YES)


我的系统是redhat的
我找这个帖子http://blog.chinaunix.net/u1/35320/showart_305024.html上操作
以及重装mysql都没用解决问题
...全文
108208 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
wqxshaog 2011-08-18
  • 打赏
  • 举报
回复
不错,很好
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
多谢,成功了
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
我没有执行啊,您看第23楼的,
[root@localhost ~]# /etc/init.d/mysql stop
Shutting down MySQL... [È·¶¨]
[root@localhost ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 24482
[root@localhost ~]# 100902 15:09:24 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
100902 15:09:24 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@localhost ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.50 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user,host,password from user;
+------+-----------------------+-----------+
| user | host | password |
+------+-----------------------+-----------+
| root | localhost | ******** |
| root | localhost.localdomain | ******** |
| root | 127.0.0.1 | ******** |
+------+-----------------------+-----------+
3 rows in set (0.00 sec)
steptodream 2010-09-02
  • 打赏
  • 举报
回复
这是你执行的
mysql> UPDATE user SET Password='********' where USER='root';

这是我说的
mysql> update mysql.user set password=PASSWORD('这里改成你的密码') where User='root';

拜托你仔细看看行吗?
steptodream 2010-09-02
  • 打赏
  • 举报
回复
mysqld_safe --user=mysql --skip-grant-tables --skip-networking启动mysql
这种方式下不能执行grant语句。
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
login as: root
root@121.101.223.215's password:
Last login: Thu Sep 2 14:39:16 2010 from 123.119.92.144
[root@localhost ~]# /etc/init.d/mysql stop
Shutting down MySQL. [È·¶¨]
[root@localhost ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 24286
[root@localhost ~]# 100902 15:03:07 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
100902 15:03:07 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@localhost ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.50 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> UPDATE user SET Password='********' where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@localhost ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]#
[root@localhost ~]#
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
root的密码我已经用上面的方法给改了,不行,我再重做一次您看看
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
这个操作我做了好多遍了,不行,因为网上好多帖子都说这样,我就照做了,不行
steptodream 2010-09-02
  • 打赏
  • 举报
回复
mysql> show database;
mysql> grant all privileges on *.* to root@'%' identified by '111111';

我让你执行的
mysql> update mysql.user set password=PASSWORD('这里改成你的密码') where User='root';
mysql> flush privileges;
mysql> quit

一样吗!》?
steptodream 2010-09-02
  • 打赏
  • 举报
回复
你9楼哪儿有这个操作?!!!
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
用mysqld_safe --user=mysql --skip-grant-tables --skip-networking启动mysql 然后进去给root把密码加上

mysql> update mysql.user set password=PASSWORD('这里改成你的密码') where User='root';
mysql> flush privileges;
mysql> quit
这个方法用了,还是不行,你看一下我在第9楼发的东西,就有这个操作过程
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
改了之后用root和空密码是能登陆的,只是用show databases不能看到数据库mysql了,所以没有进一步修改权限了,重装后现在用root进都进不去了
steptodream 2010-09-02
  • 打赏
  • 举报
回复
用mysqld_safe --user=mysql --skip-grant-tables --skip-networking启动mysql 然后进去给root把密码加上

mysql> update mysql.user set password=PASSWORD('这里改成你的密码') where User='root';
mysql> flush privileges;
mysql> quit

然后在重启mysql 用新设的密码访问
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
mysqladmin -uroot -p password
freetstar 2010-09-02
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 steptodream 的回复:]

你根本就没有设置root使用mysql的密码把!
[/Quote]
加权限重设置?
steptodream 2010-09-02
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 bjguikai 的回复:]

原来是有密码的,现在后来用mysqladmin改成无密码了,就进不去了
[/Quote]
你怎么改的?
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
原来是有密码的,现在后来用mysqladmin改成无密码了,就进不去了
steptodream 2010-09-02
  • 打赏
  • 举报
回复
你根本就没有设置root使用mysql的密码把!
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
我操作过程就是上面的,我是菜鸟,不知道怎么办,重装也不行,用tar.gz重装了,用rpm重装了都不行,
在线狂等
bjguikai 2010-09-02
  • 打赏
  • 举报
回复
login as: root
root@121.101.223.215's password:
Access denied
root@121.101.223.215's password:
Last login: Thu Sep 2 14:28:57 2010 from 123.119.92.144
[root@localhost ~]# clear
[root@localhost ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]# /etc/init.d/mysql stop
Shutting down MySQL.... [È·¶¨]
[root@localhost ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 23998
[root@localhost ~]# 100902 14:40:20 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
100902 14:40:20 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@localhost ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.50 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> grant all privileges on *.* to root@'%' identified by '111111';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> etc/init.d/mysql restart
-> quit
->
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'etc/init.d/mysql restart
quit' at line 1
mysql> quit
Bye
[root@localhost ~]# /etc/init.d/mysql restart
Shutting down MySQL.100902 14:41:50 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
[È·¶¨]
Starting MySQL. [È·¶¨]
[1]+ Done mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[root@localhost ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]#
加载更多回复(8)

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧