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
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.
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
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.
@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.
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';