Files
ghost-docker/mysql-init/create-multiple-databases.sh
James Loh e065e8667c Add migration script for Ghost CLI -> Docker installs
- This script handles the copy of both assets and the MySQL database
  from an existing install to a new Docker based install
- Its currently been tested on the "happy path" of a Ghost CLI install
  and works
2025-06-27 14:40:27 +10:00

19 lines
437 B
Bash
Executable File

#!/bin/bash
set -e
set -u
if [ -n "$MYSQL_MULTIPLE_DATABASES" ]; then
echo "Creating multiple databases: $MYSQL_MULTIPLE_DATABASES"
for db in $(echo "$MYSQL_MULTIPLE_DATABASES" | tr ',' ' '); do
echo "Creating database: $db"
mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<-EOSQL
CREATE DATABASE IF NOT EXISTS \`$db\`;
GRANT ALL ON \`$db\`.* TO '$MYSQL_USER'@'%';
EOSQL
done
echo "Multiple databases created"
fi