Docker + MySQL + HeidiSQL - fix for login to mysql client - error: Authentication plugin 'caching_sha2_password' cannot be loaded

4 points
Created by:

Hi, in this article I would like to show you how to solve the problem:

Authentication plugin 'caching_sha2_password' cannot be loaded


I use docker and I can't connect to MySQL with SQL client.

I use MySQL version 8.0

I tried 3 different MySQL clients:

  • HeidiSQL
  • MySQL Workbench
  • IntelliJ IDEA SQL client

For all of them I get error:

Authentication plugin 'caching_sha2_password' cannot be loaded:
The specified module cannot be found.

I use default root / root username and password for localhost.

Error screenshot:


# 1. Connect to docker container, open windows cmd:
docker exec -it PUT_CONTAINER_ID_HERE bash
# eg:
docker exec -it 3c4172634rd3 bash
# to get CONTAINER_ID use docker ps

# 2. Login to MySQL with root account
mysql --user=root --password=root

# 3. Set root account to use MySQL native password 
ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY 'root';

# if we want to use user different then root, we just change it in above command

Step 1, 2 and 3 on screenshot - windows cmd:

And now we are able to login to MySQL via HeidiSQL client (or any other SQL client).

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂