MySQL "身份验证插件 'caching_sha2_password'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49963383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Authentication plugin 'caching_sha2_password'
提问by nandipati vamsi
I'm new to MySql environment and installed : MySQL with the following commands:
我是 MySql 环境的新手并安装了:MySQL,使用以下命令:
sudo apt-get update sudo apt-get install mysql-server mysql_secure_installation
须藤 apt-get 更新须藤 apt-get 安装 mysql-server mysql_secure_installation
and also installed mysql workbench.
并且还安装了mysql工作台。
But when I'm trying to connect my localhost getting the follow error:
但是当我尝试连接我的本地主机时出现以下错误:
"Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory"
“无法加载身份验证插件‘caching_sha2_password’:/usr/lib/mysql/plugin/caching_sha2_password.so:无法打开共享对象文件:没有这样的文件或目录”
and even this is the first time I'm posting a question in stackoverflow, sorry for my presentation errors and syntax.
即使这是我第一次在 stackoverflow 中发布问题,对于我的演示错误和语法,我深表歉意。
回答by meow
So I found the reason for that error message (at least for my case).
It's because MySQL as of version 8.04 and onwards uses caching_sha2_password
as default authentication plugin where previously mysql_native_password
has been used.
所以我找到了该错误消息的原因(至少对于我的情况)。这是因为 MySQL 从 8.04 版及以后的版本用作以前使用caching_sha2_password
过的默认身份验证插件mysql_native_password
。
This obviously causes compatibility issues with older services that expect mysql_native_password
authentication.
这显然会导致与需要mysql_native_password
身份验证的旧服务的兼容性问题。
Solutions:
解决方案:
Check for an updated version of the client service you are using (most recent workbench for instance).
Downgrade the MySQL Server to a version below that change.
- Change the authentication plugin on a per user basis (I didn't find a global option, maybe there exists one though).
检查您正在使用的客户端服务的更新版本(例如最新的工作台)。
将 MySQL 服务器降级到低于该更改的版本。
- 基于每个用户更改身份验证插件(我没有找到全局选项,但可能存在一个)。
Now regarding option 3 this is as simple as altering the user:
现在关于选项 3,这就像更改用户一样简单:
ALTER USER user
IDENTIFIED WITH mysql_native_password
BY 'pw';
or when creating the user:
或在创建用户时:
CREATE USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
回答by Anse
Some more details coming here:
That caching_sha2_password
plugin is the new default authentication plugin on MySQL 8 server. Only the libmysql library from that MySQL 8 distribution owns this plugin, and it is built staticallyinto libmysql - the C-connector for various clients. That caching_sha2_password
is not available separately for downloading.
这里有更多详细信息:该caching_sha2_password
插件是 MySQL 8 服务器上新的默认身份验证插件。只有来自 MySQL 8 发行版的 libmysql 库拥有这个插件,并且它被静态构建到 libmysql - 各种客户端的 C 连接器中。这caching_sha2_password
是不可分开的下载。
This is the very first time that libmysql has an important plugin statically included. And this causes any other libmysql (including libmariadb and also older libmysql's) not to connect to MySQL 8 with a user which is defined to use that caching_sha2_password
authentication.
这是 libmysql 第一次静态包含一个重要的插件。这会导致任何其他 libmysql(包括 libmariadb 和较旧的 libmysql)无法使用定义为使用该caching_sha2_password
身份验证的用户连接到 MySQL 8 。
I just hope that the guys from MariaDB are so nice to also include that caching_sha2_password
in their libmariadb, to restore the drop-in-compatibility between MySQL and MariaDB.
我只是希望 MariaDB 的人caching_sha2_password
能把它包含在他们的 libmariadb 中,以恢复 MySQL 和 MariaDB 之间的直接兼容性。
From MySQL's server blog:
来自 MySQL 的服务器博客:
Support for caching_sha2_password was added in MySQL 8.0.3. Older versions of libmysqlclient do not support this plugin. So, although client tools that use libmysqlclient older than one available with MySQL 8.0.3 can connect to MySQL 8.0.4 server using users that use other authentication plugins such as mysql_native_password or sha256_password, such client cannot connect to MySQL 8.0.4 server using users which require caching_sha2_password support.For an upgraded database, it means connecting using an existing user account should not face any issues.
MySQL 8.0.3 中添加了对 caching_sha2_password 的支持。旧版本的 libmysqlclient 不支持此插件。因此,尽管使用早于 MySQL 8.0.3 可用的 libmysqlclient 的客户端工具可以使用使用其他身份验证插件(例如 mysql_native_password 或 sha256_password)的用户连接到 MySQL 8.0.4 服务器,但此类客户端无法使用用户连接到 MySQL 8.0.4 服务器这需要 caching_sha2_password 支持。对于升级后的数据库,这意味着使用现有用户帐户进行连接应该不会遇到任何问题。
回答by Seeker401
In the my.cnf file add the following line:
在 my.cnf 文件中添加以下行:
default-authentication-plugin=mysql_native_password
then restart the server.
然后重启服务器。