Issue
In GitHub Actions, I have defined a MySQL service like this:
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: localdb
services:
mysql:
image: mysql/mysql-server:5.7
ports:
- 3306:3306
Now, when I connect to this service I get:
ERROR 1130 (HY000): Host '172.18.0.1' is not allowed to connect to this MySQL server
When I installed the same service locally using Docker, I solved the very same error with this code:
$ docker exec -it mysqldb bash# mysql -h localhost -u root -p
mysql> create user 'root'@'%' identified WITH mysql_native_password by '';
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Yet I have no idea how I would do the same inside the CI pipeline, since connecting to the server to execute queries already throws the above error.
How do I configure the MySQL server to accept connections?
Solution
The service probably just had the wrong image, this works:
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: localdb
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
Answered By – Steffi S.
Answer Checked By – Robin (BugsFixing Admin)