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
网友评论