forked from KaiHofstetter/docker-wordpress-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_and_start_mysql.sh
More file actions
28 lines (20 loc) · 878 Bytes
/
Copy pathconfig_and_start_mysql.sh
File metadata and controls
28 lines (20 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
if [ ! -f /mysql_configured ]; then
echo "=> MySQL not configured yet, configuring MySQL ..."
echo "=> Setting MySQL bind address to have access from the Docker host"
sed -i 's/^bind-address\s*=.*$/bind-address = "0.0.0.0"/' /etc/mysql/my.cnf
echo "=> Starting MySQL"
/etc/init.d/mysql start &
echo "=> Waiting till MySQL is started"
mysqladmin --wait=30 ping > /dev/null 2>&1
echo "=> Creating WordPress db"
mysqladmin create wordpress
echo "=> Creating MySQL WP user and granting external access";
mysql -uroot -e "CREATE USER '$MYSQL_WP_USER'@'%' IDENTIFIED BY '$MYSQL_WP_PASSWORD';"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_WP_USER'@'%' WITH GRANT OPTION;"
touch /mysql_configured
else
echo "=> MySQL is already configured"
echo "=> Starting MySQL"
/etc/init.d/mysql start
fi