ubuntu18.04下mysql 5.7安装时没有出现设置密码提示

 

 

  前言:

  一:配置

  系统:ubuntu 18.04 

  软件:mysql 5.7.30

  

 

 

  二:问题 

  ubuntu18.04下mysql安装时没有出现密码提示,可能是bug,也许是另有原因。安装后自己有一个默认的用户名以及密码。

  解决方案:

  1. 在终端输入:

 

sudo vi /etc/mysql/debian.cnf

 


可以查看到:

user     = debian-sys-maint


password = WU2UbLLd4totyAs8

 

 

 

 

 

 

 

  2. 用该账户登陆mysql:

  注意:这里的密码是上面的{随机密码}

mysql -u debian-sys-maint -p

 

 

 

  3. 设置root的用户密码:

 

update mysql.user set authentication_string=password('123456') where user ='root' and Host='localhost';
update mysql.user set plugin = 'mysql_native_password';
flush privileges;
quit

 

 

 

 

 

 

  4. 重启mysql服务:

 

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

 

  5. 用root登陆:

 

mysql -u root -p

 

 

   声明:

   作者:HepengWu

  


————————————————------------------------------------------------------------------------------------------

参考链接:https://blog.csdn.net/Kwoky/article/details/89492074

     https://www.jianshu.com/p/161f612a971c

     

posted @ 2020-05-09 14:56  小树木  阅读(661)  评论(0编辑  收藏  举报