.. _mysql_user: mysql_user `````````````````````````````` .. versionadded:: 0.6 Adds or removes a user from a MySQL database. .. raw:: html
parameter required default choices comments
name yes
    name of the user (role) to add or remove
    login_user no
      The username used to authenticate with
      login_host no localhost
        Host running the database
        host no localhost
          the 'host' part of the MySQL username
          state no present
          • present
          • absent
          The database state
          login_password no
            The password used to authenticate with
            password no
              set the user's password
              priv no
                MySQL privileges string in the format: db.table:priv1,priv2
                .. raw:: html

                Create database user with name 'bob' and password '12345' with all database privileges

                    mysql_user name=bob password=12345 priv=*.*:ALL state=present
                    

                Ensure no user named 'sally' exists, also passing in the auth credentials.

                    mysql_user login_user=root login_password=123456 name=sally state=absent
                    

                Example privileges string format

                    mydb.*:INSERT,UPDATE/anotherdb.*:SELECT/yetanotherdb.*:ALL
                    


                .. raw:: html

                Notes

                Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as apt-get install python-mysqldb.

                Both login_password and login_username are required when you are passing credentials. If none are present, the module will attempt to read the credentials from ~/.my.cnf, and finally fall back to using the MySQL default login of 'root' with no password.