3

I have Python version 2.7 and downloaded MySQL version 8.0.13. When I try to install the correct connector from the link run it and run the following code:

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  passwd="Pass"
)

print(mydb)

The module is not recognized:

Traceback (most recent call last):
  File "C:\Users\carmel.han\Desktop\mysqltest.py", line 1, in <module>
    import mysql.connector
ImportError: No module named mysql.connector

When I install the SQL Connector using pip and run the same code I get:

Traceback (most recent call last):
  File "C:\Users\carmel.han\Desktop\mysqltest.py", line 7, in <module>
    auth_plugin='mysql_native_password'
  File "C:\Python27\ArcGIS10.4\lib\site-packages\mysql\connector\__init__.py", line 179, in connect
    return MySQLConnection(*args, **kwargs)
  File "C:\Python27\ArcGIS10.4\lib\site-packages\mysql\connector\connection.py", line 95, in __init__
    self.connect(**kwargs)
  File "C:\Python27\ArcGIS10.4\lib\site-packages\mysql\connector\abstracts.py", line 719, in connect
    self._open_connection()
  File "C:\Python27\ArcGIS10.4\lib\site-packages\mysql\connector\connection.py", line 210, in _open_connection
    self._ssl)
  File "C:\Python27\ArcGIS10.4\lib\site-packages\mysql\connector\connection.py", line 144, in _do_auth
    self._auth_switch_request(username, password)
  File "C:\Python27\ArcGIS10.4\lib\site-packages\mysql\connector\connection.py", line 167, in _auth_switch_request
    auth = get_auth_plugin(new_auth_plugin)(
  File "C:\Python27\ArcGIS10.4\lib\site-packages\mysql\connector\authentication.py", line 191, in get_auth_plugin
    "Authentication plugin '{0}' is not supported".format(plugin_name))
NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

I upgraded from pip 7.0.1 to pip 18.1, uninstalled and reinstulled the SQL-connector, same resulet.Even When I insert this line:

auth_plugin='mysql_native_password'

Based on this post here.

So I supose it might be a problem with the SQL connector version. I searched and found out you can install a specific version of the SQL - connector but I don't know which version I need.

pip installed 2.1.6 by default I also tried 2.1.4, which did not work. I'm working on Windows 10 64 bit.

Anybody have an Idea?

MBT
  • 21,733
  • 19
  • 84
  • 102
Carmel Han
  • 141
  • 6
  • Possible duplicate of [Authentication plugin 'caching\_sha2\_password' is not supported](https://stackoverflow.com/questions/50557234/authentication-plugin-caching-sha2-password-is-not-supported) – snakecharmerb Nov 10 '18 at 14:14

1 Answers1

0

First you have to install mysql-connector from below command.

python -m pip install mysql-connector

Then you would be able to run your program.

vipul prajapati
  • 263
  • 2
  • 8
  • Thats the comand I used to install the mysql-connector with pip and it does not work. I get this error then: `"NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported` – Carmel Han Nov 06 '18 at 08:15
  • Refer [https://stackoverflow.com/questions/50557234/authentication-plugin-caching-sha2-password-is-not-supported] this – vipul prajapati Nov 12 '18 at 08:06