失败缘由:密码加密方式【caching_sha2_password】,客户端不支持mysql
在数据库服务器上登陆:sql
mysql>use mysql; mysql>select user, host, plugin, authentication_string from user\G;
************************** 4. row *************************** user: root host: localhost plugin: caching_sha2_password
root 的密码是用 caching_sha2_password 插件加密的。而客户端找不到 caching_sha2_password 插件,因而登陆不上数据库
在服务器启动配置中不设置 default_authentication_plugin=mysql_native_password 的状况下,新建立的用户
都是 mysql_native_password 加密的,其实服务器默认是用 mysql_native_password 加密的;服务器
那第问题来了,既然默认是用 mysql_native_password 加密的,为何个人 root 的用户密码是用 caching_sha2_password 加密的?
多是由于首次登陆的时候经过mysql_secure_installation设置了密码的缘由,root用户 在安装数据库时,指定的加密插件是:caching_sha2_password加密
修改root用户的加密插件,修改 root 用户密码:
mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpass';插件
newpass是你的新密码code
以上解决问题string