Closed ccp999 closed 8 years ago
The init-file in MySQL is interpreted differently (each statement must only be one line), so the DELIMITER
line would not work. (https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_init-file)
I'd request the ability in the official image to import SQL during the DB init portion of the entrypoint, like sakila here, with the path of the SQL file passed in through an ENV variable.
I wonder if mysql
has something that would allow us to just start up enough of a daemon to run a file through the database and then exit so that this could be easier or cleaner than using --init-file
(which does have very odd semantics, and they change based on version or flavor of MySQL).
@tianon looks nasty, but something like this? https://github.com/tutumcloud/tutum-docker-mysql/blob/master/5.6/import_sql.sh
That's kind of what I was afraid the only real answer might me... :(
I was browsing the registry for existing implementations on how they solved this problem. I agree that this looks nasty (especially the "waits"). Also tried to figure out how (for example) puppet handles this in their mysql module (https://github.com/puppetlabs/puppetlabs-mysql), but I'm not so fluent in Ruby and could not find the relevant parts.
However, if this is branded as the official MySQL image, would it be possible to get someone at Oracle/MySQL have a look and give advise here?
Looks like should be solved now that we run the full mysqld when importing provided sql files.
Closing old issue, if you feel this was closed in error please let us know.
We ran into this problem today when we were trying to automatically import a stored procedure into MySQL every time the container starts (in case the stored procedure code has changed since last start, eg. from a pull
or something). The --init-file
option will not work because it doesn't support DELIMITER
s.
Can someone offer insight into how to do this with Docker and MySQL? We're using the mariadb
image: https://hub.docker.com/_/mariadb/
Hi,
This is not an issue with your script but I failed to make an enhancement. I want to load Sample data, Sakila (http://dev.mysql.com/doc/sakila/en/index.html) when the image run.
I added few lines in entrypoint.sh of both 5.6 and 5.7 sub directory
echo 'FLUSH PRIVILEGES ;' >> "$TEMP_FILE"
fi
chown -R mysql:mysql /var/lib/mysql exec "$@"
the newly added sql files loaded, but partly only and logs show:
2014-09-26 17:51:49 1 [Note] Execution of init_file '/tmp/mysql-first-time.sql' started. ERROR: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER ;;' at line 1 2014-09-26 17:51:49 1 [Note] Execution of init_file '/tmp/mysql-first-time.sql' ended.
the same files can be loaded successfully from in mysql shell source /tmp/sakila-db/sakila-schema.sql; source /tmp/sakila-db/sakila-data.sql;
do you know any reason?