Skip to content

Knowledgebase

Identifying the active WordPress database and table prefix

wordpress, backups

Identify the database actually used by a WordPress installation before exporting, repairing or changing data. Hosting accounts can contain several databases and older copies, so a familiar-looking database name is not enough to prove that it belongs to the live website.

01 Start with the correct installation

Find the domain's document root in the hosting account and confirm the WordPress files for that site. A subdomain or staging copy may use a different directory. Locate the active wp-config.php; some installations keep it one directory above the WordPress files or obtain values through environment-specific configuration.

02 Read the identifiers privately

  1. Open the configuration through an authorised file manager or SSH session.
  2. Identify DB_NAME, DB_HOST and the $table_prefix value. Record only what is needed for the planned task.
  3. Open the corresponding database in the hosting database tool and confirm the tables use the expected prefix.
  4. Check the site's home and siteurl options or another non-sensitive recent record to confirm that this is the intended installation.
  5. Close the configuration without changing it if this was only an identification task.

03 Example: identify database names without dumping credentials

Use selected configuration reads instead of printing the entire wp-config.php. Run them only against the verified WordPress path. The table-prefix value is a variable, while the database name is a constant.

Command example
wp --path='/home/ACCOUNT/sites/example.com' config get DB_NAME
wp --path='/home/ACCOUNT/sites/example.com' \
  config get table_prefix --type=variable

Compare the results with the hosting database list, then confirm the relevant options table belongs to the intended site. On Multisite, the network’s base prefix and a subsite’s table prefix are not interchangeable. Raw wp db query does not select different tables merely because --url is present.

Expected result: The chosen backup or diagnostic operation targets the correct database and tables. No database password, authentication salt or application secret appears in the support transcript, and an unfamiliar prefix is investigated before being labelled an obsolete copy.

Why is the prefix not wp_?

The prefix is chosen when the installation is created and can differ from the common default. Multiple installations may have different prefixes in one database. Multisite also has shared network tables and separate site tables, so the presence of several related prefixes does not automatically mean there are unused copies.

Can WP-CLI identify the same information?

Where WP-CLI is available, run its configuration and database-inspection commands from the verified installation path. Request only the values you need rather than dumping the entire configuration into a shared terminal log. Confirm the selected path explicitly when several sites exist in the account.

04 Protect credentials and avoid premature cleanup

The configuration also contains database credentials and security keys. Do not include them in screenshots, tickets or public repositories. A database that appears old may still serve a staging site or another application; identify every consumer before removing it. After confirming the active database, create a backup before any repair or replacement operation. If configuration values are generated dynamically and the effective database remains unclear, provide the domain and installation path to support without exposing passwords.

Was this answer helpful?

Need a little more help?

Our support team can help you find the next step.

Contact support