1)停止数据库 2.1)/usr/bin/mysqld_safe --skip-grant-tables 2.2)/home/data/mysql3306/mysqld_safe --defaults-file=/home/data/mysql3306/my.cnf --skip-grant-tables 占据终端 3)netstat -ntlp | grep 3306 先看看数据库启动没 4)连接 mysql -uroot 5)设置新密码 mysql> SET PASSWORD FOR root@‘localhost’ = PASSWORD(‘582945’); 不能这么修改 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> update mysql.user set password=password(‘test_1’) where user=‘root’ and host=‘localhost’; update mysql.user set password=’*E710DC2512FCF6F18FE0D652B53290DCB11F3334’ where user=‘root’ and host=‘localhost’; mysql> flush privileges; 6)kill 数据库进程 7)正常重启数据库 8)可以用新密码连接