ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法

sudo cat /etc/mysql/debian.cnf

《ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法》 image.png

mysql -u debian-sys-maint -p
//注意! 
//这条指令的密码输入是输入第一条指令获得的信息中的 password = ZCt7QB7d8O3rFKQZ 得来。
//请根据自己的实际情况填写!

《ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法》 image.png

修改密码

use mysql;
// 下面这句命令有点长,请注意。
update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password"; 
flush privileges;
quit;

《ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法》 image.png

重新启动mysql

转载自:https://blog.csdn.net/qq_38737992/article/details/81090373

    原文作者:苍简
    原文地址: https://www.jianshu.com/p/1fbf36e98bff
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞