一、忘记密码,从控制台免密码登陆:mysql
修改/etc/my.cnf,[mysqld]下加一行:skip-grant-tables
重启mysql: /etc/init.d/mysqld restart
命令行免密登陆:bin/mysql
二、用update修改密码,因为mysql的版本问题,选下面两种之一。别忘了flush privileges:sql
update user set password=password("new_pass") where user="root"; update user set authentication_string=password("new_pass") where user="root";