版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/caiqiiqi/article/details/83074210
修改mysql配置文件
sudo vi /etc/mysql/my.cnf
添加一行,(意思是mysql不需要密码登录?)
skip-grant-tables
然后重启mysql
sudo service mysql restart
空密码登录mysql
mysql -u root -p
修改mysql root密码
update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
flush privileges;
exit
重置mysql配置文件
将之前的skip-grant-tables
注释掉。
原文
https://blog.csdn.net/yelllowcong/article/details/79641313