一、忘記密碼,從控制檯免密碼登陸: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";