美文网首页Mysql
Ubuntu安装MySQL5.7时没有设置root密码解决方案

Ubuntu安装MySQL5.7时没有设置root密码解决方案

作者: Alex_Paul | 来源:发表于2019-01-03 12:03 被阅读0次
$ sudo vim /etc/mysql/debian.cnf
# 找到password一行,复制密码
$ mysql -u debian-sys-maint -p 此长密码
mysql> use mysql;
mysql> update user set authentication_string=PASSWORD("你的密码") where user='root';
mysql> update user set plugin="mysql_native_password"; # 不用修改, 直接执行
mysql> flush privileges;
mysql> quit;
$ sudo service mysql restart
# 这个时候就可以用刚刚设置的root密码登录mysql了

相关文章

网友评论

    本文标题:Ubuntu安装MySQL5.7时没有设置root密码解决方案

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