---
title: "Access the Opsview databases"
description: "Accessing the Opsview databases directly is possible but not recommended due to the risk of irreparable damage to the installation. Use the provided cx script or the API for safer access, and only connect as root when absolutely necessary."
url: "https://docs.itrsgroup.com/docs/faq/opsview/4921146151453-opsview-access-the-opsview-databases/index.html"
---
**Proceed with caution**

We do not recommend making any direct changes to the Opsview databases. Wherever possible, you should use the API instead.

Changes to the Opsview databases can irreparably damage your Opsview installation.

Always take appropriate backup precautions before making any direct changes to the Opsview databases.

Accessing the Opsview databases on the command line can be helpful for troubleshooting. However, almost everything that can be achieved by accessing the databases on the command line can also be achieved using the API. You should make changes using the API instead of the database whenever possible.

If you must access the databases directly, you should use `cx`. Only connect directly to the databases as `root` if you have no other option.

## Using `cx`

We provide a wrapper script called `cx` that simplifies the process for connecting to the Opsview databases. It connects to the specified database as the `opsview` user.

### Prerequisites

- None

### Process

1. Log in to the [orchestrator](https://docs.itrsgroup.com/docs/faq/opsview/4920429084957-opsview-orchestrator/index.html) as `root`.
2. Connect to your desired database using `cx`:

```
/opt/opsview/coreutils/utils/cx <database>
```

Replace `<database>` with the name of the database you want to access.

## Using `mysql` and the `root` user

You should only use this method if you need to connect to the database as a user other than `opsview`.

All connections to the Opsview databases are routed through the `opsview-loadbalancer` component on the orchestrator. The load balancer does not accept outside connections by default, though you can allow external connections to the database via the orchestrator. We assume that external connections are not enabled so you have to initiate the connection from the orchestrator. However, if you have enabled external connections and want to connect from a host other then the orchestrator, you can make some minor changes to the `mysql` command below:

- change the IP
- provide the password directly

### Prerequisites

- None

### Process

1. Log in to the [orchestrator](https://docs.itrsgroup.com/docs/faq/opsview/4920429084957-opsview-orchestrator/index.html) as `root`.
2. Connect to the desired database using `mysql`:

```
mysql -h 127.0.0.1 -P 13306 -u root -p$(awk '/opsview_database_root_password/ {print $2}' /opt/opsview/deploy/etc/user_secrets.yml) <database>
```

Replace `<database>` with the name of the database you want to access.


