mysql5.6以上,为了安装考虑,设置了随机密码,并且5.7.11并不能从安装日志上看到随机密码生成在了哪里
因此,mysql安装完后操作:
1.如果mysql启动出现以下错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决:
- /etc/my.cnf中添加--skip-grant-tables忽略密码登陆
- update mysql.user set authentication_string=password('123qwe') where user='root' and Host ='localhost';
新版本去掉了password字段用authentication_string存储密码
3.FLUSH PRIVILEGES;
4.退出mysql,重启mysql
2.重启登陆mysql后,出现以下错误:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决:
1.
SET PASSWORD = PASSWORD('123456');
执行此条语句出现以下错误:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决:问题原因是因为mysql加强了密码保护,增加了
validate-password加密插件
如果单纯学习使用,则在配置文件中添加
validate-password=OFF将加密插件设置启动时关闭。重启mysql。
3.顺利添加用户:grant all on *.* to nnblue@localhost identified by '1';
赋予用户本地操作权限: grant all priviledges on *.* to 'nnblue' @'%' identified by'1';