vim /etc/mysql/mysql.conf.d/mysqld.cnf
在[mysqld]段下加入一行“skip-grant-tables”
use mysql update mysql.user set authentication_string=password('new_pass') where user='root'; flush privileges;
把剛纔加入的那一行“skip-grant-tables”註釋或刪除掉。
service mysql restart
啓動:sudo service mysql start 停止:sudo service mysql stop