alpine-mariadb
alpine-mariadb copied to clipboard
prepend `use $MYSQL_DATABASE;` to .sql files
Hello, I am just wondering, how you use this feature. In my understanding those .sql files are scripts created by mysqldump for one database, that will become $MYSQL_DATABASE
of the container. In my adaption, I found the following changes useful:
for f in /docker-entrypoint-initdb.d/*; do
case "$f" in
- *.sql) echo "$0: running $f"; /usr/bin/mysqld --user=root --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"; echo ;;
- *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | /usr/bin/mysqld --user=root --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"; echo ;;
+ *.sql)
+ echo "$0: running $f"
+ { echo "use \`$MYSQL_DATABASE\`;" ; cat "$f" ; } \
+ | /usr/bin/mysqld --user=root --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0
+ echo ;;
+ *.sql.gz)
+ echo "$0: running $f"
+ { echo "use \`$MYSQL_DATABASE\`;" ; gunzip -c "$f" ; } \
+ | /usr/bin/mysqld --user=root --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0
+ echo ;;
*) echo "$0: ignoring or entrypoint initdb empty $f" ;;
esac
echo
If you could tell us more about what this does then i will merge if it's useful.
It lets you import the output of mysqldump Database
directly into the container as it will not include the database name.
https://github.com/yobasystems/alpine-mariadb/commit/0f35a0e22b3e0002989bc09ae84e6b374473cb63
This has broken the image, i'm getting
/scripts/run.sh: line 76: syntax error: unexpected "}" (expecting ";;")