版权声明:转载请标明出处 https://blog.csdn.net/gymaisyl/article/details/86567533
1.进入到debian.cnf配置文件中,获取默认的用户名和密码
命令: sudo gedit /etc/mysql/debian.cnf
运行后获得user 和 password
2.使用user和password登陆mysql
如下图
mysql -udebian-sys-maint -p
3.修改用户名和密码
use mysql
update mysql.user set authentication_string=password('mysql') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
quit;
4.完成修改后重启mysql服务器
sudo service mysql restart