Simply just put your .sql file (dbcreation.sql) in a folder (ie. /mysql_init) and add the folder as a volume like this:volumes: - /mysql_init:/docker-entrypoint-initdb.d MySQL映像将在启动时执行/docker-entrypoint-initdb.d中的所有.sql,.sh和.sql.gz文件.The MySQL image will execute all .sql, .sh and .sql.gz files in /docker-entrypoint-initdb.d on startup. 这篇关于如何使用Docker compose创建mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-13 15:58