ansible mysql_db模塊 說明

來源:本站原創 Linux 超過2,448 views圍觀 0條評論

https://www.kancloud.cn/hiyang/ansiblebook/306176

mysql_db模塊用于建立、刪除、導入和導出數據庫

建立數據庫

state="present"

---
- name: mysql
  hosts: s.hi.com
  tasks:
  - name: create a database
    mysql_db:
      login_host: "127.0.0.1"
      login_user: "root"
      login_password: "[email protected]"
      login_port: "3306"
      name: "mezz"
      encoding: "utf8"
      state: "present"
刪除數據庫

state="absent"

---
- name: mysql
  hosts: s.hi.com
  tasks:
  - name: delete a database
    mysql_db:
      login_host: "127.0.0.1"
      login_user: "root"
      login_password: "[email protected]"
      login_port: "3306"
      name: "mezz"
      state: "absent"
導出數據庫

state="dump"

---
- name: mysql
  hosts: s.hi.com
  tasks:
  - name: dump a database
    mysql_db:
      login_host: "127.0.0.1"
      login_user: "root"
      login_password: "[email protected]"
      login_port: "3306"
      name: "mezz"
      target: "/tmp/mezz.gz"
      state: "dump"
導入數據庫

state="import"

---
- name: mysql
  hosts: s.hi.com
  tasks:
  - name: import a database
    mysql_db:
      login_host: "127.0.0.1"
      login_user: "root"
      login_password: "[email protected]"
      login_port: "3306"
      name: "mezz"
      target: "/tmp/mezz.gz"
      state: "import"
文章出自:CCIE那點事 http://www.qdxgqk.live/ 版權所有。本站文章除注明出處外,皆為作者原創文章,可自由引用,但請注明來源。 禁止全文轉載。
本文鏈接:http://www.qdxgqk.live/?p=3706轉載請注明轉自CCIE那點事
如果喜歡:點此訂閱本站
?
?
萌宠夺宝游戏