长时间没登录mysql 之前又没把这个密码记录下来现在密码忘记了!网上找了一下重设mysql 密码的方法试了一下成功了!把他共享出来 给大家参考参考
先结束mysql 进程
# killall mysqld
用mysql 安全模式运行并跳过权限难
# mysqld_safe skipgranttables
用root 登录 此时不需要密码
# mysql u root
现在开始修改密码了
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with A
Database changed
mysql> update user set Password = PASSWORD(your new password) where User = root ;
Query OK rows affected ( sec)
Rows matched: Changed: Warnings:
mysql> quit
Bye
OK成功了!
注意当运行 mysqld_safe skipgranttables 后停在Starting mysqld daemon with databases from /var/lib/mysql 可以新开一个远程终端继续操作