MySQL5.7 root帐户本地访问报错问题解决
## 问题说明
MySQL5.7之后版本使用新的授权插件auth_socket
系统普通用户使用mysql root帐户登录, 会一直报错: " Access denied for user 'root'@'localhost'"
## 解决方法:
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | | auth_socket | localhost |
需要进行配置或root用户登录,否则会一直报错: " Access denied for user 'root'@'localhost'"
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Admin@123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *0A9AD07A3D1AC640F68AB9970EB4F4124925D6CB | mysql_native_password | localhost |
之后就可以在普通帐户下使用mysql用户名正常登录
## 补充说明: 初始化Mysql密码:
$ sudo mysql_secure_installation
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。