参考:
ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法_ubuntu中mysql设置密码-CSDN博客
1. use mysql; #连接到mysql数据库
2. update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost'; #修改密码123456是密码
3. update user set plugin='mysql_native_password';
4. flush privileges;
5. quit;
执行到2步报错:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(‘123456’) where user=‘root’ and Host =‘localhost’' at line 1
替换为:
mysql> SET PASSWORD = '123456';
又报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决:
ERROR 1819 (HY000) Your password does not satisfy the current policy requirements-阿里云开发者社区 (aliyun.com)
正确的完整流程如下: