django.db.utils.operationalError: (2059,“Authentication Plugin 'caching_sha2_password'”)

前端 未结 5 1911
情深已故
情深已故 2020-12-18 08:07

I am trying to connect my django project \'mysite\' to mysql. I made a user in mysql and granted it all privileges to access the project. These are the changes I made to set

相关标签:
5条回答
  • 2020-12-18 08:12

    This error is typically gotten when the DB user don't have all access to the database

    Run this command:

    ALTER  USER 'username'@'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
    

    *Make sure to have your MySQL server running.

    0 讨论(0)
  • 2020-12-18 08:17

    Actually, there is no need to downgrade the MYSQL Server. Follow these two steps and it should work:

    Step 1: Change MYSQL configuration to use mysql_native_password. Edit one of ini files that mysqld is using. You can see which one my using the command

    mysqld --verbose --help 
    

    and make sure this line is added -

    default-authentication-plugin=mysql_native_password
    

    Step 2: Create an new or alter the existing user. To create a new with mysql_native_password password:

    CREATE USER 'username'@'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
    

    and to alter user

    ALTER USER 'username'@'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
    

    By the way, this step is also pointed out by @Kol_ya

    0 讨论(0)
  • 2020-12-18 08:20

    In MySql 8.0 the default authentication plugin is 'caching_sha2_password', which causes authentication plugin issues(error 2059), one can create a new user in the MySql workbench and setting there Authentication to be standard.

    0 讨论(0)
  • 2020-12-18 08:25

    @Kol_ya created new user using CREATE USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; where username = creation of new username and password = current password to login for root(username created with caching_sha2). This step allowed me to connect to MySql Server 8.0.13 without having caching_sha2 authentication error. Looked for solution several threads but this one helped just like that. Thanks @kol_ya

    Suggestion to people who are having caching_sha2 issue. In server side make sure your user authentication type is standard not caching_sha2_password.

    0 讨论(0)
  • 2020-12-18 08:27

    The issue is (probably) your (new) version of MySQL.

    Starting with version 8.04 MySQL uses caching_sha2_password as default authentication plugin where previously mysql_native_password has been used (which causes compatibility issues with older services that expect mysql_native_password authentication).

    Possible solutions:

    Downgrade the MySQL Server to a version below that change or change the authentication plugin (on a user basis)

    eg when creating the user:

    CREATE USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    
    0 讨论(0)
提交回复
热议问题