[mysql_db模塊][1]用于建立、刪除、導入和導出數據庫
#### 建立數據庫
`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"
```
[1]:http://docs.ansible.com/ansible/latest/mysql_db_module.html
- 目錄
- ansible基礎
- ansible簡介
- ansible安裝和測試
- ansible配置文件
- 常用命令
- yaml在ansible中的用法
- inventory
- 變量與facts
- when語句
- handler模塊
- 大雜燴
- ansible模塊
- assert 模塊
- copy模塊
- cron模塊
- debug模塊
- django_manage模塊
- file模塊
- filesystem模塊
- git模塊
- hostname模塊
- lineinfile模塊
- mount模塊
- mysql_user模塊
- mysql_db模塊
- pip模塊
- selinux
- setup模塊
- shell 和 command 模塊
- stat模塊
- supervisorctl
- systemd
- timezone
- unarchive模塊
- user模塊
- wait_for
- yum和service模塊
- 其他模塊或者方法
- setup模塊
- url模塊
- slack 模塊
- pause 模塊
- 其他
- 報錯處理
- playbooks
- 復雜的playbook
- 循環
- roles
- YAML
- jinja2