mysql_db-Add or remove a MySQL database from a remote host.
- Profile
- Requirements (on the host that executes the module)
- Options
- Example
- Notes
Profile
- Add or remove a MySQL database from a remote host.
Requirements (on the host that executes the module)
- MySQLdb's
- MySQL (command line binary)
- Mysqldump (command line binary)
Options
Parameters |
need to |
default |
Select |
Notes |
Collation
|
No |
|
|
Collation mode (sort). This applies only to new tables/databases, and does not update existing tables, which is the limit for MySQL. |
Config_file (added in 2.0) |
No |
?/. my.cnf |
|
Specifies the configuration file from which to read the user and password. |
Connect_timeout (added in 2.1) |
No |
30 |
|
The connection timed out when connecting to the MySQL server. |
Encoding
|
No |
|
|
using the encoding mode, examples include utf8 orlatin1_swedish_ci |
Login_host
|
No |
localhost |
|
The host runs the database. |
Login_password
|
No |
|
|
The password to use for authentication. |
Login_port
|
No |
3306 |
|
MySQL server port. If you use Login_port, you need to define login_host as a different local host. |
Login_unix_socket
|
No |
|
|
The path to the locally attached UNIX domain socket. |
Login_user
|
No |
|
|
The user name to use for authentication. |
Name
|
Yes |
|
|
The name of the database to add or remove name = all only if Status to be dump or time is only available import . If name = all works like mysqldump's--all-databases option (added in 2.0) alias: DB |
Quick (2.1 added) |
No |
True |
|
Options for dumping large tables |
Single_transaction (2.1 added) |
No |
|
|
To perform a dump in a single transaction |
Ssl_ca (2.0 added) |
No |
|
|
the path of the certification authority (CA) certificate. This option (if used) must specify the same certificate that is used by the server. |
Ssl_cert (2.0 added) |
No |
|
|
The path to the client public key certificate. |
Ssl_key (2.0 added) |
No |
|
|
The path to the client private key. |
State
|
No |
Present |
- Present
- Absent
- Dump
- Import
|
Database status |
Target
|
No |
|
|
in the location on the remote host, the dump file reads or writes. supports uncompressed SQL files ( .sql ) as well as bzip2 ( .bz2 ), gzip (), .gz and XZ (added in 2.0) to compress files. |
Example
-Name:Create a new database with name ' Bobdata 'mysql_db:Name:BobdataState:Present# Copy database dump file to remote host and restore it to database ' my_db '-Name:Copy database dump FileCopy:Src:dump.sql.bz2Dest:/tmp-Name:Restore Databasemysql_db:Name:my_dbState:ImportTarget:/tmp/dump.sql.bz2-Name:Dump all databases to Hostname.sqlmysql_db:State:DumpName:AllTarget:/tmp/{{Inventory_hostname}}.sql- Name: import file.sql similar to Mysql-u < Username>-P <password> < hostname.sql mysql_db: state: import name: all target: /tmp/{{inventory_hostname }} .sql
Attention
- Requires the PYTHON-MYSQLDB package on the remote host, as well as the MySQL and mysqldump binaries.
- requires the MySQLdb python package on the remote host. for Ubuntu, this is as simple as Apt-get install PYTHON-MYSQLDB. (see apt.) For Centos/fedora, this is as easy as Yum to install Mysql-python. (see yum.) )
- no matter
login_password
and the login_user
your lost credentials are required. If it does not exist, the module will attempt to read the credentials from it ~/.my.cnf
, and finally go back to "root" with the MySQL default login, without the password.
State
the module is marked as Preview , which means that it does not guarantee a backward-compatible interface.
Support
This module is maintained by the community without the supervision of the core submitter.
For more information on what this means, please read the module support
to help develop the module, if you have this tendency, read the community information and contributions to test the programmable and development modules .
Ansible adding or removing a MySQL database from a remote host