vi /etc/my.cnf
在[mysqld]下面增加一行
skip-grant-tables
重启 /etc/init.d/mysqld restart
/usr/local/mysql/bin/mysql -uroot
mysql> update user set authentication_string=password('123333') where user='root';
退出来后,更改my.cnf,去掉刚加的 skip-grant-tables
重启 /etc/init.d/mysqld restart
转载于:https://www.cnblogs.com/lin1/p/5659589.html