星期四, 二月 01, 2007

MySQL 丢失 root 密码的重置

忘记 MySQL root 密码后,可以用如下方法重新设置:
sh# /etc/init.d/mysqld stop
sh# mysqld_safe --skip_grant_tables --defaults-file=/etc/my.cnf
sh# mysql -u root
mysql> update mysql.user set password=PASSWORD('********') where User='root';
OR
mysql> set password for 'root'@'localhost' = PASSWORD('********');
mysql> flush privileges;
mysql> quit
sh# /etc/init.d/mysqld stop
sh# /etc/init.d/mysqld start

没有评论: