无法在另一台启用端口转发的电脑上访问MySQL数据库

2024-09-15 04:48:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我在做一个项目,涉及服务器访问数据库。数据库是在MySQL(v8.0)上开发的,在另一台PC上是活动的。通过端口转发访问数据库是活动的,但是每当从我的PC访问数据库时,就会出现以下错误。你知道吗

"Authentication plugin '{0}' is not supported".format(plugin_name)) mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

我试着重新安装mysql-python连接器,检查了所有版本,但都检查出来了(我甚至做了另一个VM来交叉验证)。你知道吗

请帮忙。任何形式的输入将不胜感激!!你知道吗


Tags: 项目端口name服务器数据库formatauthenticationis
2条回答

谢谢你的意见。原来,这个问题是由于软件安装不当引起的。从mysql网站安装deb包时,安装可能会丢失一些关键组件,因此无法运行代码。你知道吗

我试着在终端上运行以下命令

pip install mysql-connector-python

这之后问题就消失了。你知道吗

尝试使用telnet打开到数据库运行端口的连接。 例如

phill@kore:~$ telnet localhost 3306
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
J
5.7.22q8TpMY /fT[zVmysql_native_password Connection closed by foreign host.
phill@kore:~$

在这种情况下,mysql服务希望使用mysql_native_password 这个问题可能有帮助:

Authentication plugin 'caching_sha2_password' is not supported

You're using mysql_native_password, which is no longer the default. Assuming you're using the correct connector for your version you need to specify the auth_plugin argument when instantiating your connection object

cnx = mysql.connector.connect(user='lcherukuri', password='password',
                              host='127.0.0.1', database='test',
                              auth_plugin='mysql_native_password')

同时建议尝试以下方法:

mysql> select Host,User,plugin from mysql.user;
+     -+       -+           -+
| Host      | User          | plugin                |
+     -+       -+           -+
| localhost | root          | mysql_native_password |
| localhost | mysql.session | mysql_native_password |
| localhost | mysql.sys     | mysql_native_password |

相关问题 更多 >