-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why can't I create more than one schema? #983
Comments
Unfortunately, I'm not sure what the problem might be 😅 Does the container have any useful logs when it fails? The best I can figure is that maybe the script failed, but there should be something in the logs. 👀 |
I have a few scripts that operate on two schemas. Only the scripts that use the schema defined in MYSQL_DATABASE work, the others do not. If I change the variable, the working scripts change too. Shouldn't all of them work no matter the schema on the variable? There is nothing in /var/log/mysqld.log. The logs from the container start don't say anything about the success or failure of the scripts:
Although those empty lines look suspicious... |
Can you share some representative part of the Just some guesses at debugging: If the separate scripts don't each start with a I did a quick test with the following $ docker run -it --rm -e MYSQL_DATABASE=db1 -e MYSQL_ROOT_PASSWORD=12345 -v "$PWD/data/:/var/lib/mysql/" -v "$PWD/init/:/docker-entrypoint-initdb.d/" --user "$(id -u):$(id -g)" mysql:8 CREATE DATABASE IF NOT EXISTS db2;
USE db2;
CREATE TABLE Persons ( PersonID int, Name varchar(255) );
SELECT * FROM Persons; |
Here:
1_database.sql.gz
|
I'm using mysql:8.0, with
MYSQL_DATABASE: pvet_production_db
, and two scripts in docker-entrypoint-initdb.d: one that creates all the tables and inserts data (1_database.sql.gz) and another one that does some pseudoanonymization on the data (2_anonymize.sql.gz), and both work on the schema specified on the variable (the first file has ause
statement, the second one does not but still works); up to here everything works as expected.Now I would like to add another schema, but for some reason, I can't: I added another file (0_test_database.sql.gz) which does the same as 1_database.sql.gz on a different schema, but it doesn't work. I also added 0_create_schemas.sql with just the creation statements for both schemas, but no luck. I can see these files being listed during the bootstrap of the container, but it is like nothing happens. From my testing, it looks like only the operations for the schema defined in the MYSQL_DATABASE happen.
I also added docker-library/postgres#179 (comment) (replacing
psql
withmysql
), and it is picked up but doesn't do anything either.What am I missing?
The text was updated successfully, but these errors were encountered: