腾讯云ubuntu16.04安装MySql5.7未提示密码设置且无法登陆解决

一、安装

sudo apt-get update
sudo apt install mysql-server

二、修改密码

1、由于安装过程中未提示要设置密码,且使用sudo mysql_secure_installation命令过程一直报错:Error: Access denied for user 'root'@'localhost' (using password: YES)

解决方法:

1、进入到etc/mysql目录下,查看debian.cnf文件:

sudo cat debian.cnf

 

2、查看到MySql的用户名、密码,并登录:

用户名: debian-sys-maint
密码:bgZ3yhfFiou0mfGY

登录: mysql -udebian-sys-maint -pbgZ3yhfFiou0mfGY

 

3、修改用户名和密码

show databases;

use mysql;

update user set authentication_string=PASSWORD("你自己的密码") where user='root';

update user set plugin="mysql_native_password";

flush privileges;

quit;

4、重启MySql

/etc/init.d/mysql restart

5、正常登录

猜你喜欢

转载自www.cnblogs.com/darklights/p/11595344.html