prepopulated-mysql-container-example icon indicating copy to clipboard operation
prepopulated-mysql-container-example copied to clipboard

Adding database name env. variable for a new database

Open laeeq80 opened this issue 6 years ago • 3 comments

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

laeeq80 avatar Jun 30 '19 15:06 laeeq80

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.

lindycoder avatar Jul 02 '19 13:07 lindycoder

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.

laeeq80 avatar Jul 02 '19 17:07 laeeq80

You could add ENV MYSQL_DATABASE=whatever to the Dockerfile instead.

Mizzrym avatar Sep 23 '21 06:09 Mizzrym