Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Developer · Guide

How to Find WordPress Database Name (Step by Step)

How to Find WordPress Database Name (Step by Step)

Short answer

Open wp-config in your site's root folder and read the value in the DB_NAME line. If you cannot reach the files, go to Tools, then Site Health, open the Info tab and expand Database. On the command line, run wp config get DB_NAME with WP-CLI.

Key takeaways

  • The DB_NAME line in wp-config.php holds the database name.
  • Site Health's Info tab shows it to administrators.
  • WP-CLI can print it with wp config get DB_NAME.
  • Hosting panels list every database, not just the one in use.
  • Check siteurl in phpMyAdmin to confirm the right database.
  • Never share database credentials in screenshots or tickets.

How do you find your WordPress database name?

Open the wp-config.php file in your site's root folder and look for the DB_NAME line; the value in quotes is the database name your site uses.

Every WordPress site stores its posts, pages, settings and users in a MySQL or MariaDB database. The site knows which database to use because of a few lines in its configuration file.

You might need the name to back up the site, restore a backup, fix a database connection error, or find the right database in phpMyAdmin when a hosting account has several.

This guide covers five ways to find it, from the file itself to your hosting panel, Site Health and WP-CLI.

Which method should you use?

Use wp-config.php if you have file access, Site Health if you only have dashboard access, and WP-CLI if you work over SSH.

MethodWhat you needBest when
wp-config.php fileFile Manager, FTP or SFTPYou have hosting access
Site Health Info screenAdmin login to WordPressYou cannot reach the files
WP-CLISSH accessYou manage sites from the command line
Hosting control panelHosting loginYou want to see all databases on the account
phpMyAdminHosting loginYou want to confirm tables and the prefix

All of them point to the same answer. The wp-config.php file is the source of truth, since that is what WordPress actually reads.

Step 1: How do you find it in wp-config.php?

Open your hosting File Manager or connect by SFTP, go to the folder where WordPress is installed, open wp-config.php, and read the value in the DB_NAME line.

The file is usually in the main site folder, often called public_html or www, next to the wp-admin and wp-content folders. Our guide on where to find wp-config.php covers less common locations.

Look for lines like these near the top:

define( 'DB_NAME', 'example_wp123' );
define( 'DB_USER', 'example_user' );
define( 'DB_PASSWORD', '...' );
define( 'DB_HOST', 'localhost' );

The first line holds the database name. The others give the username, password and server WordPress uses to connect. The WordPress documentation on the wp-config.php file explains each setting.

Only view the file. Do not change anything unless you mean to, because one wrong character can take the site offline.

If File Manager opens the file in an editor, close it without saving. Some editors add hidden characters or change line endings when you save, even if you did not type anything.

Step 2: How do you find it with Site Health?

Go to Tools, then Site Health, open the Info tab, and expand the Database section, where WordPress lists the database name, user, host and table prefix.

This works when you can log in to WordPress but cannot reach the files, which is common on managed hosting or client sites.

The Site Health screen documentation describes the Info tab. Only administrators can see it. Our guide on using Site Health in WordPress covers the other checks on this screen.

Some details in this section are marked as private. They are hidden when you use the Copy site info button, so you can share the report with support without exposing them.

Step 3: How do you find it with WP-CLI?

Connect to the server over SSH, change to the WordPress folder, and run wp config get DB_NAME to print the database name.

WP-CLI reads the same wp-config.php file, so the answer matches. The command looks like this:

wp config get DB_NAME

The wp config get reference lists other values you can read, such as DB_HOST and the table prefix.

You can also run wp db query with a SQL statement to confirm which database the site connects to. Our list of useful WP-CLI commands includes more database tools.

Step 4: How do you find it in your hosting control panel?

Log in to your hosting panel and open the databases section, such as MySQL Databases in cPanel, to see every database on the account.

This shows all databases, not only the one WordPress uses. If you host several sites, there may be many, so match the name against wp-config.php before doing anything.

Panels name databases in different ways. On cPanel, names often start with your account username and an underscore. Managed WordPress hosts may hide databases entirely and offer only a phpMyAdmin link.

Plesk, DirectAdmin and custom host panels follow the same idea with different labels. Look for a menu item called Databases or MySQL, which lists each database with its users.

If you cannot find a database section at all, ask your host. Some managed WordPress hosts only expose the database through their own tools or a support request.

If you are setting up a new site rather than finding an existing one, our guide on creating a database for WordPress covers the steps.

Step 5: How do you confirm it in phpMyAdmin?

Open phpMyAdmin from your hosting panel, look at the list of databases in the left sidebar, and click the one that matches DB_NAME to see its WordPress tables.

A WordPress database contains tables such as wp_posts, wp_options and wp_users. The wp_ part is the table prefix, which may be different on your site.

To be certain you have the right database on an account with several sites, open the options table and check the siteurl and home rows. They show the site's address.

Also look at the table prefix. If one database holds tables with two different prefixes, two sites share it. Match the prefix with the table prefix line in wp-config.php to see which tables belong to your site.

The phpMyAdmin documentation explains the interface. If you prefer SQL, the SHOW DATABASES statement lists databases your user can access.

Why might the database name not match what you expect?

The site may use a different database than you assumed because of a migration, a staging copy, a multisite setup, or a host that renamed it.

Common situations:

  • Old databases left behind after a migration or reinstall. The account shows several, but only one is in use.
  • Staging sites that have their own database with a similar name.
  • Table prefixes that let several sites share one database. In that case, the name is the same, but each site uses different prefixed tables.
  • Remote database servers, where DB_HOST points to another server and the database does not appear in your local panel.

Always trust the wp-config.php value over the hosting panel's list.

What should you do if you see a database connection error?

Check that DB_NAME, DB_USER, DB_PASSWORD and DB_HOST in wp-config.php match a real database and user, and that the user has privileges on that database.

A wrong database name is one cause of the Error establishing a database connection message. Others include a wrong password or a database server that is down.

Our guide to fixing the database connection error walks through each check in order.

If you need to edit wp-config.php and the host does not allow it, see our guide on fixing unable to write to wp-config.php.

How do you keep database details safe?

Never share wp-config.php or the database password in public forums, screenshots or support tickets, and back up the database before making changes.

The database name alone is not very sensitive, but it often appears next to the username and password. Crop or blur screenshots before sending them.

Before any database work, such as restoring tables or running search and replace, make a backup. Our guide on backing up a WordPress database explains plugin, panel and command line options.

What else is stored alongside the database name?

The same part of wp-config.php holds the database user, password, host, character set and the table prefix setting, all of which WordPress needs to connect.

Knowing these together helps with migrations:

  • DB_USER and DB_PASSWORD: the login WordPress uses.
  • DB_HOST: usually localhost, but sometimes a separate server name or port.
  • DB_CHARSET: normally utf8mb4 on modern installs.
  • $table_prefix: the prefix in front of every table name.

When you move a site, you create a new database on the new host and update these values to match. The database name on the new host can be different, as long as wp-config.php points to it.

Frequently asked questions

Where is the WordPress database name stored?

It is stored in the wp-config.php file in your WordPress root folder, on the line that defines DB_NAME. WordPress reads this file on every request to know which database to connect to. The same section holds the database user, password and host.

Can I find the database name without FTP access?

Yes. Log in as an administrator, go to Tools, then Site Health, open the Info tab and expand the Database section. It lists the database name, user, host and table prefix. Your hosting panel's database section or phpMyAdmin are other options.

Why does my hosting account show several databases?

Each WordPress install, staging copy or old reinstall can have its own database, and old ones often stay behind after migrations. Only the database named in wp-config.php is in use by your site. Check it before deleting or changing anything.

Is the database name the same as the table prefix?

No. The database name identifies the whole database, while the table prefix, often wp_, is added to the start of each table name inside it. Several WordPress sites can share one database by using different prefixes.

Can I change the WordPress database name?

Yes, but you need to create or rename the database in your hosting panel, make sure the database user has access to it, and update DB_NAME in wp-config.php. Take a full backup first, because a mismatch takes the site offline with a connection error.

Sources

  1. wp-config.php WordPress Developer Resources
  2. Site Health Screen WordPress.org Documentation
  3. wp config get WordPress Developer Resources
  4. phpMyAdmin Documentation phpMyAdmin
  5. SHOW DATABASES Statement MySQL

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.