mysql的docker容器如何設置默認的數(shù)據(jù)庫技巧詳解
更新時間:2023年10月31日 09:19:56 作者:ponponon
這篇文章主要為大家介紹了mysql的docker容器如何設置默認的數(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ù)庫的超級用戶訪問權限(對應于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ù)據(jù)庫技巧詳解的詳細內容,更多關于mysql docker設置默認數(shù)據(jù)庫的資料請關注腳本之家其它相關文章!
相關文章
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日志命令的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Mysql具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-09-09