简体   繁体   中英

Unable to access MySQL Database on another PC with port forwarding on

I am working on a project which involves a server accessing a database. The database is developed on MySQL (v8.0) and is active on another PC. The access to the database is active via port forwarding, but whenever the database is accessed from my PC, the following Error comes up.

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

I have tried reinstalling the mysql python connector and checked all the versions for the same but they all check out (I even made another VM to cross verify the same!).

Please help with this. Any kind of input would be appreciated!!

Try using telnet to open a connection to the port your database is running on. Eg

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:~$

In this case the mysql service is expecting to use mysql_native_password Possibly this question might help:

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') 

Also sugested is to try something like this:

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 |

Thanks for the input. Turns out, that the problem is caused due to improper installation of the software. When installing the deb package from the mysql website, the installation probably misses some key components because of which it is not able to run the code.

I tried running the following command on the terminal

pip install mysql-connector-python

The problem disappeared after this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM