mysql - Create database on docker-compose startup - Stack Overflow

PHOTO EMBED

Wed Feb 24 2021 20:06:09 GMT+0000 (Coordinated Universal Time)

Saved by @faisalhumayun #sql #docker

-- create the databases
CREATE DATABASE IF NOT EXISTS projectone;

-- create the users for each database
CREATE USER 'projectoneuser'@'%' IDENTIFIED BY 'somepassword';
GRANT CREATE, ALTER, INDEX, LOCK TABLES, REFERENCES, UPDATE, DELETE, DROP, SELECT, INSERT ON `projectone`.* TO 'projectoneuser'@'%';

FLUSH PRIVILEGES;
content_copyCOPY

https://stackoverflow.com/questions/43322033/create-database-on-docker-compose-startup