python – Authentication plugin 'caching_sha2_password' is not supported-ThrowExceptions

Exception or error:

I am trying to connect to a MySQL server with python connector. I created a new user lcherukuri with the authentication plugin mysql_native_password.

But I got the error

mysql.connector.errors.NotSupportedError: Authentication plugin ‘caching_sha2_password’ is not supported

Can someone help me?

import mysql.connector

cnx = mysql.connector.connect(user='lcherukuri', password='password',

enter image description here

How to solve:

Per Caching SHA-2 Pluggable Authentication

In MySQL 8.0, caching_sha2_password is the default authentication plugin rather than mysql_native_password.

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='', database='test',

From those same docs:

The connect() method supports an auth_plugin argument that can be used to force use of a particular plugin. For example, if the server is configured to use sha256_password by default and you want to connect to an account that authenticates using mysql_native_password, either connect using SSL or specify auth_plugin='mysql_native_password'.


I had the same problem and passing auth_plugin='mysql_native_password' did not work, because I accidentally installed mysql-connector instead of mysql-connector-python (via pip3). Just leaving this here in case it helps someone.


This question is already answered here and this solution works.

caching sha2 password is not supported mysql

Just try this command :

pip install mysql-connector-python


None of the above solution work for me. I tried and very frustrated until I watched the following video:

pip uninstall mysql-connector work on some computer and it might not work for other computer.

I did the followings:

The mysql-connector causes problem.

  1. pip uninstall mysql-connector

    The following may not need but I removed both connector completely.

  2. pip uninstall mysql-connector-python

    re-install mysql-conenct-python connector.

  3. pip install mysql-connector-python


Modify Mysql encryption

ALTER USER 'lcherukuri'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';


I had this same issue but my resolution was different because this didn’t completely work.

I found this on a GitHub forum – copy and paste this into your terminal. You don’t have to change your password; it can be the exact same.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '{NewPassword}';


You can go to Settings->Project->Project Interpreter and here install latest version of mysql-connector-python package. In my case it was mysql-connector-python 8.0.15.


To have a more permanent solution without going through your code and modifying whatever needs to be modified:
Per MySQL 8 documentation, easiest way to fix this is to add the following to your MySQL d file -> restart MySQL server.

This worked for me!

If your MySQL installation must serve pre-8.0 clients and you encounter compatibility issues after upgrading to MySQL 8.0 or higher, the simplest way to address those issues and restore pre-8.0 compatibility is to reconfigure the server to revert to the previous default authentication plugin (mysql_native_password). For example, use these lines in the server option file:

#add the following file to your MySQLd file


Please install below command using command prompt.

pip install mysql-connector-python

enter image description here


I ran into the same problem as well.
My problem was, that I accidentally installed the wrong connector version.
Delete your currently installed version from your file system (my path looks like this: C:\Program Files\Python36\Lib\site-packages) and then execute
“pip install mysql-connector-python”.
This should solve your problem


i try to resolve this error and finally install PyMySQL instead of mysql library
and it’s working properly.



If you are looking for the solution of following error

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Acces
s is denied: ‘D:\softwares\spider\Lib\site-packages\libmysql.dll’
Consider using the --user option or check the permissions.

The solution:
You should add --user if you find an access-denied error.

 pip install --user mysql-connector-python

paste this command into cmd and solve your problem

Leave a Reply

Your email address will not be published. Required fields are marked *