Skip to content

Commit 343f7a3

Browse files
committed
Use password for MySQL in CI to avoid connection issues
MySQL with empty password seems to have connection issues in CI. Using a test password for more reliable connections.
1 parent 038f23e commit 343f7a3

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.github/workflows/example.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,30 @@ jobs:
7070

7171
- name: Wait for MySQL
7272
run: |
73+
# Wait for MySQL to be ready inside container
7374
for i in {1..30}; do
74-
if docker exec $(docker compose ps -q mysql) mysql -uroot -e "SELECT 1" >/dev/null 2>&1; then
75-
echo "MySQL is ready"
75+
if docker exec $(docker compose ps -q mysql) mysql -uroot -ptestpass -e "SELECT 1" >/dev/null 2>&1; then
76+
echo "MySQL is ready inside container"
7677
break
7778
fi
7879
echo "Waiting for MySQL..."
7980
sleep 2
8081
done
82+
83+
# Give MySQL more time to accept external connections
84+
echo "Waiting for MySQL to accept external connections..."
85+
sleep 5
86+
8187
# Create the test database
82-
docker exec $(docker compose ps -q mysql) mysql -uroot -e "CREATE DATABASE testdb;"
88+
docker exec $(docker compose ps -q mysql) mysql -uroot -ptestpass -e "CREATE DATABASE testdb;"
89+
90+
# Debug: Check MySQL status and users
91+
echo "Checking MySQL users and permissions..."
92+
docker exec $(docker compose ps -q mysql) mysql -uroot -ptestpass -e "SELECT user, host FROM mysql.user WHERE user='root';"
93+
8394
# Test connection from host
8495
echo "Testing connection from host..."
85-
mysql -h 127.0.0.1 -P 3306 -u root -e "SHOW DATABASES;" || echo "Direct connection failed, but that's OK if mysqldef can connect"
96+
mysql -h 127.0.0.1 -P 3306 -u root -ptestpass -e "SHOW DATABASES;" || echo "Note: Direct MySQL client connection failed"
8697
8798
- name: Preview MySQL schema changes
8899
uses: ./
@@ -92,7 +103,7 @@ jobs:
92103
baseline-schema-file: examples/mysqldef-current.sql
93104
schema-file: examples/mysqldef-desired.sql
94105
mysql-user: root
95-
mysql-password: ''
106+
mysql-password: 'testpass'
96107
mysql-host: 127.0.0.1
97108
mysql-port: 3306
98109
mysql-database: testdb

compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
mysql:
33
image: mysql:${MYSQL_VERSION:-8.0}
44
environment:
5-
MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
5+
MYSQL_ROOT_PASSWORD: 'testpass'
66
MYSQL_ROOT_HOST: '%'
77
volumes:
88
- ./.docker/mysql/data:/var/lib/mysql

0 commit comments

Comments
 (0)