mysql的docker容器如何設(shè)置默認的數(shù)據(jù)庫技巧詳解
正文
使用 MYSQL_DATABASE 環(huán)境變量就行
This variable is optional and allows you to specify the name of a database to be created on image startup. If a user/password was supplied (see below) then that user will be granted superuser access (corresponding to GRANT ALL) to this database.
這個變量是可選的,允許您指定要在映像啟動時創(chuàng)建的數(shù)據(jù)庫的名稱。如果提供了用戶/密碼(見下文),那么該用戶將被授予對該數(shù)據(jù)庫的超級用戶訪問權(quán)限(對應(yīng)于GRANT ALL)。
示例
version: "3" mysql8: container_name: mysql8 image: mysql:8.0.34 restart: always ports: - "3306:3306" environment: - MYSQL_ROOT_PASSWORD=Ep7zMmBfXm4y3wx - MYSQL_DATABASE=image_search_engine volumes: - ./volumes/mysql/:/var/lib/mysql - ./my-custom.cnf:/etc/mysql/conf.d/my-custom.cnf
像上面這樣就創(chuàng)建了一個名為 image_search_engine 的默認 database
以上就是mysql的docker容器如何設(shè)置默認的數(shù)據(jù)庫技巧詳解的詳細內(nèi)容,更多關(guān)于mysql docker設(shè)置默認數(shù)據(jù)庫的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
MySQL之終端Terminal(dos界面)管理數(shù)據(jù)庫、數(shù)據(jù)表、數(shù)據(jù)的基本操作
這篇文章主要介紹了MySQL之終端(Terminal)管理數(shù)據(jù)庫、數(shù)據(jù)表、數(shù)據(jù)的基本操作,需要的朋友可以參考下2015-03-03Mysql數(shù)據(jù)庫清理binlog日志命令詳解
這篇文章主要給大家介紹了Mysql數(shù)據(jù)庫清理binlog日志命令的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學(xué)習(xí)或者使用Mysql具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09