---
title: Install & configure NRDOT for MySQL monitoring with CLI
source: https://docs.newrelic.com/docs/opentelemetry/db360/mysql/cli
---

You can install and configure the NRDOT Collector for MySQL monitoring using the New Relic CLI. The CLI installs the collector, creates the monitoring user, and configures the collector in a single command.

> #### 💡 TIP
>
> To install this through the New Relic UI instead, go to  **[one.newrelic.com](https://one.newrelic.com) > Integrations & Agents > MySQL (OpenTelemetry)** . Follow the on-screen instructions to set up the integration.

## Prerequisites [#prerequisites]

-   A New Relic account with a valid [license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#overview-keys).
-   A New Relic [account ID](https://docs.newrelic.com/docs/accounts/accounts-billing/account-structure/account-id).
-   MySQL 5.7 or later.
-   A Linux collector host running Debian/Ubuntu or RHEL/CentOS, with `curl` and `systemd` installed, and the `mysql` client available.
-   For self-hosted MySQL: administrative access to your MySQL server (the `root` account or equivalent).
-   For AWS RDS/Aurora MySQL: network connectivity from the collector host to the RDS endpoint (inbound access on the MySQL port in the RDS security group), and the RDS master username and password.
-   Network connectivity to the [New Relic OTLP endpoint](https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp) for your region.

For detailed requirements, refer to [Compatibility and prerequisites](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/compatibility).

## Install and configure the NRDOT Collector [#cli-install]

**Self-hosted MySQL**

This recipe monitors one or more MySQL instances from a single collector. Instead of prompting for a single host/port/credential set, it reads two files you create ahead of time: an instances file (YAML) listing every instance to monitor, and a secrets file (`KEY=VALUE`) with an admin login and password for each, indexed to match.

1.  Create the instances file. Add one entry per MySQL instance you want this collector to monitor; just one entry if you're only running a single instance:

    ```bash
    cat > ~/mysql-instances.yml << 'EOF'
    instances:
      - host: localhost
        port: 3306
        login_name: newrelic
    EOF
    ```

2.  Create the secrets file with an admin login (any full-admin user works; it doesn't have to be `root`) and password for each instance, indexed to match the instances file's order:

    ```bash
    umask 077
    cat > ~/mysql-secrets.env << 'EOF'
    NR_CLI_MYSQL_ADMIN_USER_1=root
    NR_CLI_MYSQL_ADMIN_PASSWORD_1=YourRootPassword1
    EOF
    chmod 600 ~/mysql-secrets.env
    ```

```bash
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=INSERT_YOUR_API_KEY NEW_RELIC_ACCOUNT_ID=INSERT_YOUR_ACCOUNT_ID NEW_RELIC_REGION=INSERT_YOUR_REGION /usr/local/bin/newrelic install -n nrdot-collector-mysql
```

> #### ⚠️ IMPORTANT
>
> This installer connects to MySQL over TCP using a password, so the admin account in your secrets file must use password-based authentication. On some Debian/Ubuntu installs, `root`@`localhost` defaults to the `auth_socket` plugin (no password, local-socket only), which won't work here. Switch it first by running this locally as root:
>
> ```bash
> mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>';"
> ```
>
> If that fails with `Access denied`, the `mysql-server` package also creates a `debian-sys-maint` account with known admin credentials in `/etc/mysql/debian.cnf`. Use it instead:
>
> ```bash
> mysql --defaults-file=/etc/mysql/debian.cnf -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>';"
> ```

The CLI prompts interactively for the following variables. You can also set them ahead of time as environment variables to run non-interactively.

| Variable                      | Description                                                                                   | Default |
| ----------------------------- | --------------------------------------------------------------------------------------------- | ------- |
| `NR_CLI_MYSQL_CONFIG_PRESET`  | NRDOT configuration: 1 for Basic 2 for Advanced                                               | `1`     |
| `NR_CLI_MYSQL_INSTANCES_FILE` | Required. Path to the instances YAML file.                                                    | None    |
| `NR_CLI_MYSQL_SECRETS_FILE`   | Required. Path to the secrets file (`KEY=VALUE`, one admin login/password pair per instance). | None    |

> #### 💡 TIP
>
> To monitor more than one MySQL instance from this collector, add more entries to the instances file and matching numbered credentials (`_2`, `_3`, ...) to the secrets file. An instance that fails its checks is skipped with a logged reason rather than aborting the whole install. The install only fails outright if none of the instances pass.

**AWS RDS/Aurora MySQL**

This recipe monitors one or more RDS MySQL or Aurora endpoints from a single collector, using the same instances file / secrets file pattern as self-hosted.

1.  Create the instances file, using the RDS endpoint as `host`; just one entry if you're only monitoring a single RDS instance:

    ```bash
    cat > ~/mysql-instances.yml << 'EOF'
    instances:
      - host: mydb1.abcdefg12345.us-east-1.rds.amazonaws.com
        port: 3306
        login_name: newrelic
    EOF
    ```

2.  Create the secrets file with the RDS master username and password for each instance, indexed to match the instances file's order:

    ```bash
    umask 077
    cat > ~/mysql-secrets.env << 'EOF'
    NR_CLI_MYSQL_ADMIN_USER_1=admin
    NR_CLI_MYSQL_ADMIN_PASSWORD_1=YourMasterPassword1
    EOF
    chmod 600 ~/mysql-secrets.env
    ```

```bash
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=INSERT_YOUR_API_KEY NEW_RELIC_ACCOUNT_ID=INSERT_YOUR_ACCOUNT_ID NEW_RELIC_REGION=INSERT_YOUR_REGION /usr/local/bin/newrelic install -n nrdot-collector-mysql-rds
```

The CLI prompts interactively for the following variables. You can also set them ahead of time as environment variables to run non-interactively.

| Variable                      | Description                                                                                           | Default |
| ----------------------------- | ----------------------------------------------------------------------------------------------------- | ------- |
| `NR_CLI_MYSQL_CONFIG_PRESET`  | NRDOT configuration: 1 for Basic 2 for Advanced                                                       | `1`     |
| `NR_CLI_MYSQL_INSTANCES_FILE` | Required. Path to the instances YAML file, using RDS endpoints as `host`.                             | None    |
| `NR_CLI_MYSQL_SECRETS_FILE`   | Required. Path to the secrets file (`KEY=VALUE`, one RDS master username/password pair per instance). | None    |

> #### 💡 TIP
>
> To monitor more than one RDS MySQL or Aurora endpoint from this collector, add more entries to the instances file and matching numbered credentials to the secrets file. An instance that fails its checks is skipped with a logged reason rather than aborting the whole install.

## Find and use your data [#find]

Once your data is being collected, you can access comprehensive MySQL database monitoring through the New Relic UI.

To find your MySQL database entity in New Relic:

1.  Go to **[one.newrelic.com](https://one.newrelic.com) > All capabilities > Databases**.
2.  From the **Entity type** dropdown, select **MySQL instance**, then click **Apply**.
3.  Select your MySQL database from the list of entities.

To confirm data is arriving, run this query in the [query builder](https://docs.newrelic.com/docs/query-your-data/explore-query-data/query-builder/introduction-query-builder/):

```sql
SELECT count(*) FROM Metric
WHERE metricName LIKE 'mysql.%'
AND instrumentation.provider = 'opentelemetry'
SINCE 10 minutes ago
```

## Related documentation [#related]

[Introduction to MySQL monitoring with NRDOT](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/introduction)

Learn about all the available installation methods for MySQL monitoring with New Relic.

[Ansible install](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/ansible)

Learn how to install and configure MySQL monitoring at scale with the newrelic.newrelic_install Ansible role.

[Chef install](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/chef)

Learn how to install and configure MySQL monitoring at scale with the newrelic-install Chef cookbook.

[Helm chart install](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/helm)

Learn how to install and configure MySQL monitoring on Kubernetes with the mysql-otel Helm chart.

[Docker install](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/docker)

Learn how to run the NRDOT Collector as a sibling container to a MySQL instance already running in Docker.
