0

I am trying a simple blog project in Django with MySQL as database server and installed the mysqlclient adaptor. Made changes in the settings.py as below:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'test',
        'USER': 'root',
        'PASSWORD': 'i1nt9bt7',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}

But when I am typing "python manage.py migrate" after starting the mysql service it's giving me error that looks something like this:

django.db.utils.OperationalError: (2006, "Authentication plugin 'caching_sha2_password' cannot be loaded: /home/sandip/anaconda3/lib/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory")

I m using Ubuntu as my OS. When I revert back to Postgresql and make changes in the settings.py file it works fine. But I can work with MySQL when I am write simple Python desktop applications. Problem arises when I try it with Django. Please help.

Sandip Nath
  • 622
  • 2
  • 8
  • 18
  • Possible duplicate of [Authentication plugin 'caching\_sha2\_password' cannot be loaded](https://stackoverflow.com/questions/49194719/authentication-plugin-caching-sha2-password-cannot-be-loaded) – Keith John Hutchison Dec 18 '18 at 04:58

1 Answers1

0

It is because in the new maria versions the root user is not allowed to login via password, unless you change the mysqld config. So i recommend to create a specific user to your project.

try to change the user authentication method in mysql:

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

or create a new user:

GRANT ALL on database.* to 'username'@'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
flush privileges;

or you can find the solution here: Authentication plugin 'caching_sha2_password' cannot be loaded

ensarman
  • 190
  • 3
  • 8
  • If you don't mind I have 2 questions about your solution: what did you mean by mysql_native_password? Ans while creating new user shouldn't te command have privileges keyword in the command after GRANT ALL? – Sandip Nath Dec 18 '18 at 17:14