如果 MySQL 正在运行,首先杀之: killall -9 mysqlpid。 启动 MySQL :safe_mysqld --skip-grant-tables & 就可以不需要密码就进入 MySQL 了。 然后就是
>use mysql
>update user set password=password("new_pass") where user="root" and host='localhost';
>flush privileges;
重新杀 MySQL ,用正常方法启动 MySQL 。