What does wp-config.php do? It tells WordPress which database to connect to, which set of tables belongs to the site, and which installation-level settings to use. WordPress reads it early, before it loads plugins or themes. That’s why a mistake in this one file can take down both the public site and the dashboard.
Think of it as the wiring diagram, not the contents of the house. It doesn’t contain your posts, users, or media library. It tells WordPress where to find the database that holds your posts and users; uploaded media files are normally stored separately under wp-content.
What’s inside wp-config.php?
- Database connection settings.
DB_NAMEnames the database;DB_USERandDB_PASSWORDidentify the database account;DB_HOSTtells WordPress where to connect. The host value can include a port or socket, depending on the server. Use the value your hosting provider specifies rather than assuming it’slocalhost. - The table prefix.
$table_prefixtells WordPress which tables to look for inside that database. If a standard single-site installation useswp_, WordPress expects tables such aswp_optionsandwp_posts. A successful database connection doesn’t mean WordPress is looking at the right tables. - Authentication keys and salts. These secret values help secure login cookies. Rotating them invalidates existing WordPress login cookies, so users have to sign in again. It does not change their account passwords.
- Installation-level options. You may see settings such as
WP_DEBUG, URL overrides such asWP_HOMEandWP_SITEURL, or Multisite constants. They aren’t present in every installation. The absence of a setting isn’t, by itself, a problem.
Some managed hosts read database credentials from environment variables or a separate configuration file. If you see a reference rather than a literal password, check your host’s documentation before changing it. The file may be pointing to the setting, not storing the setting itself.
Find and inspect the active configuration safely
- Confirm the domain’s document root. In your hosting panel, open the domain settings and look for the document root, then open that path in File Manager or connect over SFTP. Look for the WordPress directory containing
wp-adminandwp-includes. It may bepublic_html, a domain-specific folder, or a subdirectory. - Find
wp-config.php, notwp-config-sample.php. The sample is a template and editing it won’t affect an installed site. If the active file isn’t in the WordPress directory, check one level above it: WordPress can load it from there under certain layouts. If the host manages configuration elsewhere, ask which file or panel controls it. Don’t create a second copy just to see what happens. - Make a private copy before editing. Download the current file to a secure location. Don’t leave a renamed copy in a public directory: the server may serve that copy as plain text. Treat the file like a password, not an attachment for a support ticket.
- Edit only the setting you mean to change. Use your host’s editor or a plain-text code editor. Find the existing definition rather than adding a duplicate, preserve the surrounding PHP syntax, and test on staging when possible. If you need a new constant in a conventional configuration, place it above the line that loads
wp-settings.php.
After saving, check the public site and wp-admin. A cached homepage can look perfectly healthy while WordPress itself is failing, so don’t use it as your only check. If an edit breaks the site and you haven’t changed anything outside the file, restoring your private pre-edit copy is the quickest rollback. If you also rotated a database password, the old file may no longer have valid credentials.
Moving a site? Match the connection and the tables
On a new host, there are two separate checks: can WordPress connect to the destination database, and can it find the migrated tables inside it? Confirm the database name, account, and database host in the destination control panel. Check that the account is assigned to the intended database with the permissions your host requires for WordPress. Then use the host’s database viewer, such as phpMyAdmin, to compare the imported table names with $table_prefix. If the imported tables include site7_options and site7_posts, the prefix for that single-site installation is site7_.

Changing $table_prefix does not rename tables, and changing DB_NAME does not import them. Likewise, extracting a .wpress archive gives you files to inspect; the archive doesn’t run WordPress. A manual restore still needs a working WordPress installation with the site files in place, an imported database, and configuration that connects the two. An archive that’s encrypted, unsupported, or damaged may not extract at all.
Troubleshoot by what you see
“Error establishing a database connection”
Start with the four connection settings, not the prefix. Compare them privately with the host’s database panel and check whether the database password recently changed. Verify that the database account can access the named database. If the settings match and the site was working before, check with the host about database availability before resetting credentials. A password reset can break another application that uses the same account.
The WordPress installer appears after a move
Stop before clicking through. The installer can appear when WordPress connects but doesn’t find the expected site tables. Check that you selected the right database, that the import completed, and that $table_prefix matches the imported tables. The installer is not a repair button; proceeding can create a fresh set of tables and make it harder to tell which set belongs to the original site.
A blank page or HTTP 500 appears right after an edit
Open the PHP error log in your hosting panel if it’s available. A parse error naming wp-config.php points to a syntax problem; check the reported line and the line just above it for a missing quote, parenthesis, or semicolon. Roll back the file first if the live site is down. Don’t turn on public error display to diagnose it: visitors don’t need a tour of your server paths.
The site redirects to the old domain
Check whether WP_HOME or WP_SITEURL is defined. The first controls the public site address; the second tells WordPress where its application files are accessible. They can legitimately differ when WordPress lives in a subdirectory. These constants override the corresponding database settings but don’t rewrite old links in posts. If there’s no override, check the site URL settings, then look for a host or CDN redirect before adding new constants.