prepopulated-mysql-container-example
prepopulated-mysql-container-example copied to clipboard
Adding database name env. variable for a new database
Hi,
I tested your example and it was working fine but then when I changed the database, it was giving error of
ERROR 1046 (3D000) at line 22: No database selected
Then I solved it by adding the env variable for the database.
--Laeeq
Hi @laeeq80 , thanks for your interest.
I saw your issue and yeah in my example, i create the database in the setup.sql.
CREATE DATABASE myexample;
If i had more script to add, personnally i would put a use myexample at the top of my other sql files.
You can use the MYSQL_DATABASE in your setup, but it should be a database name, in this PR you put the name of the setup sql file which doesn't really makes sense to me.
Got it, My case worked because my database name and sql file were same. you can change it to myexample rather than setup if you want.
You could add
ENV MYSQL_DATABASE=whatever
to the Dockerfile instead.