DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,503 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on

🐳<docker, mysql, rails> error: 'Plugin caching_sha2_password could not be loaded' when run 'db:create'

πŸ€” Problem

error: 'Plugin caching_sha2_password could not be loaded'

πŸ˜† Solution

change the IDENTIFIED to mysql_native_password

πŸ‘ŒProcedure

1.

$ docker cp hoge.sql [cotaier-id]:/hoge.sql
Enter fullscreen mode Exit fullscreen mode

2. Login to Docker

$ docker ps
$ docker exec -it [container-id] /bin/bash
Enter fullscreen mode Exit fullscreen mode

3. Login to MySQL

$ mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

4. check and alter the root user ones.

Assume that the password is 'password'.

mysql> SELECT user, host, plugin FROM mysql.user;
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| root             | %         | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| root             | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)

mysql> alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> alter user 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT user, host, plugin FROM mysql.user;
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| root             | %         | mysql_native_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| root             | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)
Enter fullscreen mode Exit fullscreen mode

Parent Note

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.