ubuntu18.04安装mysql没有密码提示解决办法

版权声明:转载请注明来源谢谢! https://blog.csdn.net/qq_43004728/article/details/84778811

最近一直被问到ubuntu18.04在安装mysql过程中没有出现ubuntu16.04过程中那样出现密码提示,这里简单说一下
mysql安装后自己有一个默认的用户名以及密码,不过不是root
1查看默认的用户以及密码:

sudo vi /etc/mysql/debian.cnf

2记录用户名以及密码(可以用该账号登录不用重新设置)
以下步骤为设置账户和密码:

 3 mysql -u debian-sys-maint -p
     Enter password 输入记录下来的密码

4进入到mysql里

5设置用户密码(假设为123456)

update mysql.user set authentication_string = password('123456') where user='root' and Host='localhost'

更改密码,然后出现一个警告

6解决警告:

update mysql.user set plugin='mysql_native_password';

7更改所有权退出关闭打开

flush privileges
quit

#停止mysql 服务

sudo /etc/init.d/mysql stop

#启动mysql

sudo /etc/init.d/mysql stop

#按照root进入

mysql -u root -p 123456

此时可以顺利进入
完毕
注意:注意符号必须是英文符号
卸载:
sudo apt-get autoremove --purge mysql-server-5.7
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common
残余清理
dpkg -l |grep ^rc|awk ‘{print $2}’ |sudo xargs dpkg -P

猜你喜欢

转载自blog.csdn.net/qq_43004728/article/details/84778811