一,在MySQL 8.0.11中,caching_sha2_password是默认的身份验证插件,而不是以往的mysql_native_password。有关此更改对服务器操作的影响以及服务器与客户端和连接器的兼容性的信息,请参阅caching_sha2_password作为首选的身份验证插件。(翻译自https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html)
今天在Mac 上配置安装mysql8.0.11时,设置mysql密码,设置成功后在终端下输入mysql -u root -p,再输入密码能正常进入,但在phpmyadmin提示无法连接,具体报错信息为:
mysqli_real_connect(): The server requested authentication method unknown to the client [sha256_password]
解决方法:在mysql的配置文件上添加一些代码:要在[mysqld]位置上。但在mac上找不到my.conf文件。只能自己手动添加:
将加密方式改为旧的,在配置文件my.conf中添加如下:
[mysqld]
default_authentication_plugin=mysql_native_password
my.conf具体内容为下:
# Example MySQL config file for small systems. # # This is for a system with little memory (<= 64M) where MySQL is only used # from time to time and it's important that the mysqld daemon # doesn't use much resources. # # MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You can copy this option file to one of those # locations. For information about these locations, see: # http://dev.mysql.com/