美文网首页
Ubuntu 18.04 MySQL 5.7不再弹出root密码

Ubuntu 18.04 MySQL 5.7不再弹出root密码

作者: 小亮_85e5 | 来源:发表于2018-05-14 14:12 被阅读0次

MySQL 5.7不再弹出root密码设置
sudo vi /etc/mysql/debian.cnf

显示:

Automatically generated for Debian scripts. DO NOT TOUCH!

[client]
host = localhost
user = debian-sys-maint
password = fPw**********22
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password =fPw**********22
socket = /var/run/mysqld/mysqld.sock

找到了,用户名:debian-sys-maint,密码:fPw**********22(这是随机生成的)
退出来,Esc键,输入“:q!”
mysql -u debian-sys-maint -p
Enter password:输入刚才找到的密码

接下来,设置root用户密码(假设为123456)

mysql> update mysql.user set authentication_string=PASSWORD(“123456″) where User=’root’;
更改root密码,然后出现
Query OK, 1 row affected, 1 warning (0.12 sec)
Rows matched: 1 Changed: 1 Warnings: 1

mysql> update mysql.user set plugin=”mysql_native_password”;
解决出现警告的问题,然后出现
Query OK, 1 row affected (0.02 sec)
Rows matched: 4 Changed: 1 Warnings: 0

mysql> flush privileges;
更新所有权限,然后出现
Query OK, 0 rows affected (0.33 sec)

mysql> quit;

退出来,先关闭再启动MySQL
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

用root用户和密码进去看看
mysql -u root -p

Reference:http://tieba.baidu.com/p/5679939196

相关文章

网友评论

      本文标题:Ubuntu 18.04 MySQL 5.7不再弹出root密码

      本文链接:https://www.haomeiwen.com/subject/piaddftx.html