免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1109 | 回复: 0
打印 上一主题 下一主题

MySQL修改密码失败 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-20 09:46 |只看该作者 |倒序浏览
[root@132 ~]# service mysqld stop
停止 MySQL:                                               [确定]
[root@132 ~]# mysqld_safe --skip-grant-tables &
[1] 2219
[root@132 ~]# Starting mysqld daemon with databases from /var/lib/mysql

[root@132 ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> update user set password=password("123456") 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> exit
Bye
[root@132 ~]# service mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
110328 10:30:16  mysqld ended

停止 MySQL:                                               [确定]
启动 MySQL:                                               [确定]
[1]+  Done                    mysqld_safe --skip-grant-tables
[root@132 ~]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

网络 上有很多办法,但是我发现都不成功,后来经过某位大师的提醒,说是MySQL的user数据库有空白行,删掉之后就OK。果然。

mysql> select User,Password from user;
+------+------------------+
| User | Password         |
+------+------------------+
| root | 565491d704013245 | 
| root | 565491d704013245 | 
| root | 565491d704013245 | 
|      |                  | 
|      |                  | 
+------+------------------+
5 rows in set (0.00 sec)

mysql> delete from user where user="";
Query OK, 2 rows affected (0.01 sec)

mysql> select User,Password from user;
+------+------------------+
| User | Password         |
+------+------------------+
| root | 565491d704013245 | 
| root | 565491d704013245 | 
| root | 565491d704013245 | 
+------+------------------+
3 rows in set (0.00 sec)

mysql> update user set password=password("123456") where user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3  Changed: 0  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@132 ~]# service mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
110328 11:53:24  mysqld ended

停止 MySQL:                                               [确定]
启动 MySQL:                                               [确定]
[1]+  Done                    mysqld_safe --skip-grant-tables
[root@132 ~]# 
[root@132 ~]# 
[root@132 ~]# mysql -h localhost -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Bye
[root@132 ~]# mysql -h localhost -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@132 ~]# 
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP