ubuntu16.04 安装mysql5.7及修改root密码
1、安装
sudo apt-get update
sudo apt install mysql-server或者指定版本sudo apt install mysql-server-5.7
2、修改root密码
sudo mysql
use mysql
select user,plugin,authentication_string from user;
此处为修改root的登录方式
update user set plugin='mysql_native_password' where user='root';
update user set authentication_string=PASSWORD('你的密码') where user='root';
此处可以提示Your password does not satisfy the current policy requirements,因为密码不符合mysql的安全策略
可以先执行
set global validate_password_policy=LOW;
再执行
update user set authentication_string=PASSWORD('你的密码') where user='root';
然后重启 mysql,不重启可能登录不上
service mysql restart
最后 mysql -u root -p 然后登录成功!
我的记录比较简单,主要为了让自己不要在工作中犯同样的错误。
参考了工作在浏览器上人-YangBobin的https://www.cnblogs.com/springsnow/p/12206227.html#_label1 谢谢!

浙公网安备 33010602011771号