1.vi /etc/my.cnf
2.在[mysqld]下添加skip-grant-tables,然后保存并退出
3.重启phpstudy restart
4./phpstudy/mysql/bin/mysql -uroot -proot登录
5.UPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE User='root';
6.FLUSH PRIVILEGES;
原文:https://blog.csdn.net/ilmusic51519/article/details/79248196