docker-compose with multiple databases

后端 未结 6 696
天涯浪人
天涯浪人 2020-12-25 10:51

I\'m trying to figure out how to implement docker using docker-compose.yml with 2 databases imported from sql dumps.

httpd:
    container_name: webserver
            


        
6条回答
  •  长发绾君心
    2020-12-25 11:34

    Just as an update to anyone else who may look into this.

    I solved this by removing:

    MYSQL_DATABASE: dbname 
    

    from docker-compose.yml and adding the relevant create database statements directly to the sql file being passed to docker-entrypoint-initdb.d.

    At that stage, sql commands are performed under root, so you'll also need to add a statement to grant relevant permissions to the database user you want to use.

提交回复
热议问题