Chinaunix首页 | 论坛 | 博客
  • 博客访问: 40315
  • 博文数量: 26
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 16
  • 用 户 组: 普通用户
  • 注册时间: 2016-12-15 11:11
文章分类

全部博文(26)

文章存档

2019年(1)

2010年(9)

2009年(1)

2008年(9)

2006年(6)

我的朋友

分类: Mysql/postgreSQL

2008-06-24 12:04:32


mysql 恢复密码


OS:
[root@localhost ~]# cat /etc/redhat-release
CentOS release 4.4 (Final)
Mysql Version:
version: 4.1.20-log

注:Mysql 为系统自带。

step 1:

mysqld_safe --skip-grant-tables  &

[root@localhost ~]# ps ux
root      4976  0.2  0.2  5328 1160 pts/1    S+   11:43   0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables

[root@localhost ~]# netstat -ant|grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      


step 2:

[root@localhost ~]# /usr/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.20-log

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

mysql> use mysql;
Database changed
mysql> update user set password=password('') where user='root';
Query OK, 0 rows affected (0.01 sec)
Rows matched: 1  Changed: 0  Warnings: 0

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

mysql> quit
Bye

[root@localhost ~]# ps ux
root      4976  0.0  0.2  5328 1160 pts/1    S+   11:43   0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
[root@localhost ~]# kill -9 4976

[root@localhost ~]# /etc/init.d/mysqld start
Starting MySQL:  [  OK  ]
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.20-log

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

mysql>

阅读(1291) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~