9

when running this code:

    import MySQLdb 
     db = MySQLdb.connect( host = '127.0.0.1', port=3307, user = 'root', 
     passwd = 'root', db = 'root') 
     cursor = db.cursor()
     db.close()

display:

OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.\r\n")

shilovk
  • 11,718
  • 17
  • 75
  • 74
shimaa
  • 91
  • 1
  • 1
  • 5

6 Answers6

16

I faced the same issue and it may be because encryption of the password; you can change the encryption of the password using the following statement:

ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';

Run this SQL query (e.g. in MySQL Workbench) but make sure to change your username and password accordingly.

For more details: Authentication plugin 'caching_sha2_password' cannot be loaded

Latika
  • 161
  • 2
13

Go to MySQL Workbench -> Server-> Users and Privileges

  1. Click Add Account

  2. Under Login Tab provide new details and make sure to choose the Authentication Type as standard and choose respective administrative roles and Schema Privileges

enter image description here

enter image description here

Nimantha
  • 6,405
  • 6
  • 28
  • 69
3

Go to the cmd and type mysql -u root -p

Enter password: *****your password

mysql>ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
Plutian
  • 2,276
  • 3
  • 14
  • 23
dev_abhi
  • 31
  • 1
  • 4
2

Running this dockerized, localhost likely is not your hostname. Try this instead:

ALTER USER 'user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

tvgriek
  • 1,215
  • 9
  • 20
1

hey I thought I'd make a stackoverflow account just to answer this because I struggled with this issue for too long, and Stackoverflow has been super helpful to me. a few things, which you may know:

1) the problem is due to the new authentication method for passwords via MySQL, so what I did was uninstalled the new MySQL and went with the oldest version I immediately saw, which I think was 5.5 instead of the current.

2) There could be some issue with having root pass + root user but I doubt it

3) Typically MySQL is open on port 3306, but maybe you changed it on purpose not sure

Anyways number 1) should fix it. gl

kentonpalmer
  • 255
  • 2
  • 16
-1

i have suffered the same problem then i unistalled the mysql and again installed it but the problem is still there. There is not a problem with mysql. But the problem is with python whether you are using python 32-bit and mysql 64-bit then may be you can face this problem. Use python 64-bit. This problem is eassly resolved. After downloading Python install connector using...

 `pip install mysqlclient`

orpip install --only-binary :all: mysqlclient keep space properly.