Chinaunix首页 | 论坛 | 博客
  • 博客访问: 82211
  • 博文数量: 32
  • 博客积分: 1526
  • 博客等级: 上尉
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-28 13:56
文章分类

全部博文(32)

文章存档

2012年(1)

2011年(15)

2010年(1)

2009年(15)

我的朋友
最近访客

分类: Mysql/postgreSQL

2011-03-28 12:24:10

[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 ~]# 
阅读(1054) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:过滤脚本

给主人留下些什么吧!~~