# Database access

> Browse and edit tables in the dashboard, run SQL, see the database credentials, generate a new password, set the IP allowlist, and open phpMyAdmin in one click.

Source: https://docs.wpwaterfall.com/database-access

The Database tab lets you browse tables, edit rows, and run SQL on an environment's MariaDB database without a separate tool. phpMyAdmin is one click away.

## How do I open it?

1. Open a site and pick the environment in the top bar.
2. Choose **Database**.
3. Read the warning, then choose **Open database**.

Changing a database directly can break a site. On live, try the change on staging first. Tick **Don't show me this warning again** to go straight to the tables next time. That choice stays in this browser only.

## Browse tables

The left panel lists every table. Search it, refresh it, or choose **+** to start a new table in the SQL console. Pick a table to see its rows.

- **Columns** show their type under the name. A key icon marks the primary key.
- **Filter** narrows rows (equals, contains, starts with, is NULL, and more). **Sort** orders them by one or more columns. Selecting a column name sorts by it.
- **Columns** hides the columns you do not need.
- The pager shows which rows you see, such as **1 - 50 of 1,234**. The **...** menu changes the page size, exports the view as CSV (up to 10,000 rows), and copies the page.
- Long values are cut at 1,000 characters. Open a cell to see all of it, up to 1 MB. JSON is shown formatted, and you can copy the value.

## Edit rows

Double-click a cell, or select it and press **Enter**, to edit it. Long text opens in a larger editor. **Add record** adds a new row at the top. Select rows and choose **Delete** to mark them.

Nothing changes until you choose **Save changes**. All the changes go in one job, and the job is written to **User Activity** with the table name and the counts, never the values.

- On **live**, WP Waterfall asks you to confirm before it saves.
- Deleting rows always asks first.
- A table with no primary or unique key can only be read here, because WP Waterfall cannot tell one row from another. Use the SQL console or phpMyAdmin.

## Secret values

In the table browser and in CSV exports, WP Waterfall hides secret values behind `********`: `user_pass` and `user_activation_key` of the users table, session tokens and application passwords in the user meta table, and options whose names look like secrets (keys, tokens, licenses, passwords, and the options WP Waterfall writes itself). You cannot sort or filter on a hidden column. People with the credentials permission and a recent password confirmation see the real values. API keys always see them hidden.

## Schema

**Schema** shows every table with its rows, size, and engine. Pick a table to see its columns, types, defaults, indexes, and foreign keys.

## SQL console

Write one statement and choose **Run** (or press **Ctrl+Enter**).

- Reads (`SELECT`, `SHOW`, `DESCRIBE`, `EXPLAIN`) run straight away, in a read-only transaction, and return up to 1,000 rows. Because a statement can read password hashes and session tokens, the console asks for the credentials permission (owners, admins, and developers) and a password confirmation in the last 10 minutes. Other roles can still browse tables.
- A statement that changes data needs the same access when it reads or writes password hashes, for example an `UPDATE` that copies `user_pass` into another column, an `INSERT ... SELECT` from the users table, or a `SELECT ... FOR UPDATE`. Other changes need only the database permission.
- An API key can run a statement only with the `sites:write` scope, and only when the person who made it may reveal credentials. A read-only key cannot. No key can run a statement that reads or writes a password hash (the `user_pass` and `user_activation_key` columns, or `SELECT *` from the users table), and none can run one that builds its SQL at run time (`PREPARE`, `EXECUTE`, `CALL`, `HANDLER`). Use the console as a signed in person for those.
- A statement that changes data needs **Allow changes** turned on. On staging it starts on. On live it starts off, and turning it on asks you to confirm.
- Each statement stops after a few seconds. Add a `WHERE` clause or a `LIMIT` to large queries.
- **History** keeps your last statements in this browser. **Copy results** copies the rows as tab separated text for a spreadsheet.

## Where are the credentials?

Choose **Database access** at the top right of the Database tab. The panel shows everything in one place:

- **Database name** and **Database username**, each with a copy button.
- **Database password**, hidden at first. The eye shows it, after you confirm your account password, and the reveal is written to User activity. It hides again after a minute.
- The circular arrow next to the password generates a new one. WP Waterfall asks you to confirm, runs a job that sets the password and updates `wp-config.php` at the same time, and then shows the new password once. Tools that use the old password stop connecting until you give them the new one.
- **IP allowlist** shows which addresses can reach the database through the SSH tunnel. It is the same list as for SFTP and SSH. Choose the pencil to change it. An empty list allows every address.
- **Open phpMyAdmin** signs you in to phpMyAdmin in a new tab, for this site's database only. phpMyAdmin can read every table, so it needs the credentials permission (owners, admins, developers, and site admins), and it opens on one click with no confirmation step. An API key can open it only when the person who made it may reveal credentials. Each link works once and expires after 60 seconds. The phpMyAdmin session then lasts up to four hours, or 30 minutes without use. Choose it again for a new link.

Press **Escape** or click outside the panel to close it. The host, port, and SSH tunnel command are on the site's **Info** page.

## Does WP Waterfall install database security fixes?

Yes, by itself. Every site runs MariaDB 12.3, and each night it installs the newest patch release of that line, such as 12.3.4 to 12.3.5. The database restarts when one is installed, which takes a few seconds, and a visitor in that moment may see one error. A patch release never moves your site to a new major version of MariaDB.

## Limits

- Grid pages show up to 500 rows.
- One save changes up to 100 rows.

## Quick answers

**phpMyAdmin says to open it from WP Waterfall.**
The link was used, it expired, or the session ended. Choose **Open phpMyAdmin** again.

**How do I import a SQL file or repair a table?**
Open phpMyAdmin from **Database access** and use its **Import** tab, or select a table and choose **Repair table**. The API also has `POST /v1/environments/{id}/database/import` and `POST /v1/environments/{id}/database/check`.

**How do I connect a desktop database tool?**
Run the SSH tunnel command from the site's **Info** page in a terminal and leave it open. Then connect your tool to host `127.0.0.1` and the port in that command, with the database user and password from **Database access**. Use `127.0.0.1`, not `localhost`, because many tools treat `localhost` as a local socket and skip the tunnel. Your SSH key must be on the environment, and your address must be on the IP allowlist when the list is not empty.

**Why can't I edit this table?**
It has no primary or unique key, or it is a view. Change it with the SQL console or phpMyAdmin.

**Can my AI assistant read the database?**
Yes, through the `query_database` tool of the WP Waterfall MCP server. It can only read. Changes stay with people in this tab.

**Does editing live break the rule that live is read only?**
No. Live code is read only. Database content can change, and WP Waterfall asks you to confirm each change on live.

## API

- `GET /v1/environments/{id}/database`
- `GET /v1/environments/{id}/database/tables`
- `GET /v1/environments/{id}/database/tables/{table}`
- `POST /v1/environments/{id}/database/tables/{table}/rows/query`
- `POST /v1/environments/{id}/database/tables/{table}/rows/cell`
- `POST /v1/environments/{id}/database/tables/{table}/rows/export`
- `POST /v1/environments/{id}/database/tables/{table}/rows` (live needs `confirm: true`)
- `POST /v1/environments/{id}/database/query`
- `POST /v1/environments/{id}/database/execute` (live needs `confirm: true`)
- `POST /v1/environments/{id}/database/phpmyadmin-session`
- `GET /v1/environments/{id}/credentials/database`
- `POST /v1/environments/{id}/credentials/rotate`
- `POST /v1/environments/{id}/database/check`
- `POST /v1/environments/{id}/database/import`

## Related

- [Site information](https://docs.wpwaterfall.com/site-info)
- [Search and replace in the database](https://docs.wpwaterfall.com/tools-search-replace)
- [Backups](https://docs.wpwaterfall.com/backups)
