Authentication

This provider requires authentication.

  • username: MySQL username (required: True, sensitive: False)
  • password: MySQL password (required: True, sensitive: True)
  • host: MySQL hostname (required: True, sensitive: False)
  • database: MySQL database name (required: False, sensitive: False)
  • port: MySQL port (required: False, sensitive: False)

In workflows

This provider can be used in workflows.

As “step” to query data, example:

steps:
    - name: Query mysql
      provider: mysql
      config: "{{ provider.my_provider_name }}"
      with:
        query: {value}  # Query to execute
        as_dict: {value}  # If True, returns the results as a list of dictionaries
        single_row: {value}  # If True, returns only the first row of the results
        # Arguments will me passed to the query.format(**kwargs)

As “action” to make changes or update data, example:

actions:
    - name: Query mysql
      provider: mysql
      config: "{{ provider.my_provider_name }}"
      with:
        query: {value}  # Query to execute
        as_dict: {value}  # If True, returns the results as a list of dictionaries
        single_row: {value}  # If True, returns only the first row of the results
        # Arguments will me passed to the query.format(**kwargs)

Check the following workflow examples:

Connecting with the Provider

In order to connect to the MySQL database, you will need to create a new user with the required permissions. Here’s how you can do this:

  1. Connect to the MySQL server as a user with sufficient privileges to create a new user.
  2. Run the following command to create a new user: CREATE USER '<username>'@'<host>' IDENTIFIED BY '<password>';
  3. Grant the necessary permissions to the new user by running the following command: GRANT ALL PRIVILEGES ON <database>.* TO '<username>'@'<host>';

Notes