ubuntu18.04安装mysql设置密码
有些教程设置完密码,还是拒绝连接,应该是密码的格式不正确,不符合mysql的默认格式,设置密码的时候,再将user表plugin字段设置为mysql_native_password(默认root的plugin字段auth_socket)就可以设置比较简单的密码了
官方文档身份验证插件.
user表plugin和 authentication_string列存储身份验证插件和凭据信息。
服务器使用plugin帐户行列中命名的插件 来验证帐户的连接尝试。
// 查看默认用户名,密码
sudo cat /etc/mysql/debian.cnf
//输出的信息包含
user = debian-sys-maint
password = huDyLqJxljwiThs5
//登录
mysql -udebian-sys-maint -phuDyLqJxljwiThs5
//使用user数据库
use mysql;
update user set authentication_string=PASSWORD("mypwd") where user='root';
update user set plugin="mysql_native_password";
flush privileges;
退出,重启mysql.