MySQL恢复root密码
时间:2007-09-05 来源:Ksharp
To reset a forgotten mysql root password you have to start MySQL by bypassing all privileges and reset the root password. It is highly suggest you do this in single user mode, since it is still possible for every user to access the mysql.sock, if you haven't changed privileges. What you should do:
/etc/init.d/mysql stop
/usr/bin/mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
use mysql;
UPDATE user SET Password=PASSWORD("your password here") WHERE User="root";
exit
# kill all the mysql processes
/etc/init.d/mysql stop
# Start MySQL again
/etc/init.d/mysql start
/usr/bin/mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
use mysql;
UPDATE user SET Password=PASSWORD("your password here") WHERE User="root";
exit
# kill all the mysql processes
/etc/init.d/mysql stop
# Start MySQL again
/etc/init.d/mysql start
至于停mysql的方法有很多,我是查出进程直接kill:)
ps -ef|grep mysql
kill -9 进程号
还可以
/bin/kill `cat /var/run/mysqld/mysqld.pid` 2>; /dev/null
附一条修复mysql数据库表的命令
/usr/local/bin/mysqlcheck -uroot -p -r [database name]
相关阅读 更多 +