ansible mysql_db模块 说明

来源:本站原创 Linux 超过150 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: "mysql@123"
      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: "mysql@123"
      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: "mysql@123"
      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: "mysql@123"
      login_port: "3306"
      name: "mezz"
      target: "/tmp/mezz.gz"
      state: "import"
文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3706转载请注明转自CCIE那点事
如果喜欢:点此订阅本站
  • 相关文章
  • 为您推荐
  • 各种观点

暂时还木有人评论,坐等沙发!
发表评论

快捷键:Ctrl+Enter