- MySQLdb的
参数 | 需要 | 默认 | 选择 | 注释 |
---|---|---|---|---|
append_privs (1.4 加入)
|
no | no |
|
将priv定义的权限附加到此用户的现有权限,而不是覆盖现有的权限。
|
check_implicit_admin (1.3 加入)
|
no | no |
|
检查mysql是否允许以root / nopassword身份登录,然后再尝试提供的凭据。
|
CONFIG_FILE (2.0 加入)
|
no | ?/ .my.cnf |
指定要从中读取用户和密码的配置文件。
|
|
connect_timeout (2.1 加入)
|
no | 30 |
连接到MySQL服务器时的连接超时。
|
|
encrypted(加密) (2.0 加入)
|
no | no |
|
表示‘密码‘字段是一个`mysql_native_password`哈希值
|
host |
no | localhost |
the ‘host‘ part of the MySQL username
|
|
host_all (2.1加入)
|
no | no |
|
覆盖host选项,使给定用户对所有主机名进行ansible应用更改。创建用户时不能使用此选项
|
login_host |
no | localhost |
运行数据库的主机。
|
|
login_password |
no |
用于验证的密码。
|
||
login_port |
no | 3306 |
MySQL服务器端口。如果使用login_port,则需要将login_host定义为其他本地主机。
|
|
login_unix_socket |
no |
到本地连接的Unix域套接字的路径。
|
||
login_user |
no |
用于验证的用户名。
|
||
name |
yes |
添加或删除的用户名称(角色)
|
||
password |
no |
设置用户密码。
|
||
priv |
no |
MySQL特权字符串格式为:
db.table:priv1,priv2 。可以通过使用正斜杠分隔每个特权来指定多个权限:
db.table:priv/db.table:priv 。该格式基于MySQL
GRANT 语句。数据库和表名可以引用,MySQL风格。
如果使用列权限,则该
priv1,priv2 部分必须与SHOW GRANT 语句完全相同。如果不遵循,模块将始终报告更改。它包括通过permission(SELECT(col1,col2 )而不是SELECT(col1 SELECT(col2))分组列)。 |
||
SQL_LOG_BIN (2.1加入)
|
no | yes |
|
是否应该为连接启用或禁用二进制日志记录。
|
ssl_ca (2.0加入)
|
no |
证书颁发机构(CA)证书的路径。此选项(如果使用)必须指定与服务器使用的相同的证书。
|
||
ssl_cert (2.0加入)
|
no |
客户端公钥证书的路径。
|
||
ssl_key (2.0加入)
|
no |
客户端私钥的路径。
|
||
state | no | present |
|
用户是否应该存在 当
absent时 删除用户。 |
update_password (2.0加入)
|
no | always |
|
如果不同,always将更新密码。
on_create 只会为新创建的用户设置密码。 |
# Removes anonymous user account for localhost - mysql_user: name: ‘‘ host: localhost state: absent # Removes all anonymous user accounts - mysql_user: name: ‘‘ host_all: yes state: absent # Create database user with name ‘bob‘ and password ‘12345‘ with all database privileges - mysql_user: name: bob password: 12345 priv: ‘*.*:ALL‘ state: present # Create database user with name ‘bob‘ and previously hashed mysql native password ‘*EE0D72C1085C46C5278932678FBE2C6A782821B4‘ with all database privileges - mysql_user: name: bob password: ‘*EE0D72C1085C46C5278932678FBE2C6A782821B4‘ encrypted: yes priv: ‘*.*:ALL‘ state: present # Creates database user ‘bob‘ and password ‘12345‘ with all database privileges and ‘WITH GRANT OPTION‘ - mysql_user: name: bob password: 12345 priv: ‘*.*:ALL,GRANT‘ state: present # Modify user Bob to require SSL connections. Note that REQUIRESSL is a special privilege that should only apply to *.* by itself. - mysql_user: name: bob append_privs: true priv: ‘*.*:REQUIRESSL‘ state: present # Ensure no user named ‘sally‘@‘localhost‘ exists, also passing in the auth credentials. - mysql_user: login_user: root login_password: 123456 name: sally state: absent # Ensure no user named ‘sally‘ exists at all - mysql_user: name: sally host_all: yes state: absent # Specify grants composed of more than one word - mysql_user: name: replication password: 12345 priv: "*.*:REPLICATION CLIENT" state: present # Revoke all privileges for user ‘bob‘ and password ‘12345‘ - mysql_user: name: bob password: 12345 priv: "*.*:USAGE" state: present # Example privileges string format # mydb.*:INSERT,UPDATE/anotherdb.*:SELECT/yetanotherdb.*:ALL # Example using login_unix_socket to connect to server - mysql_user: name: root password: abc123 login_unix_socket: /var/run/mysqld/mysqld.sock # Example of skipping binary logging while adding user ‘bob‘ - mysql_user: name: bob password: 12345 priv: "*.*:USAGE" state: present sql_log_bin: no # Example .my.cnf file for setting the root password # [client] # user=root # password=n<_665{vS43y
注意
login_password
和login_user
你逝去的凭据是必需的。如果不存在,则模块将尝试从中读取凭据~/.my.cnf
,最后回到使用MySQL默认登录的“root”,没有密码。该模块被标记为预览,这意味着它不能保证具有向后兼容的界面。
原文:http://www.cnblogs.com/mhc-fly/p/7082805.html