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>
阅读(1327) | 评论(0) | 转发(0) |