MySQL Setup Procedure for Specific Version [Docker Edition]
Here’s how to set up a MySQL server with a specific version using Docker.
docker run \
--name mysql5.7 \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-p 3306:3306 \
-d mysql:5.7
docker exec -it mysql5.7 bash
The important point is to execute queries for not only @“localhost” but also @”%” .
CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'myuser'@"localhost" IDENTIFIED BY "mypassword";
CREATE USER 'myuser'@"%" IDENTIFIED BY "mypassword";
GRANT all ON mydb.* TO 'myuser'@"localhost";
GRANT all ON mydb.* TO 'myuser'@"%"; # For Docker for Mac, don't forget @"%"; as well
FLUSH PRIVILEGES;
For details, please refer to MySQL ユーザのホストをワイルドカードで指定してもlocalhostは含まれない | b.l0g.jp.
That’s all from the Gemba.