How to Edit wp-config.php File in WordPress?

how-to-edit-wp-config-php-file-in-wordpress-themaverickspirit Pin It

Have you read a blog post across the internet asking you to edit wp-config.php file of your WordPress website?

Well, you must have!

Because wp-config.php is one of the most important files you encounter while WordPress installation.

You need to edit it for many reasons which include security, database settings, and other configuration details.

This article will give you an exact idea of “How to properly edit the wp-config.php file in WordPress?”

Cloudways-wordpress-hosting-themaverickspirit

Explore the step-by-step guide to edit wp-config.php WordPress file and secure it. 


What is wp-config.php File?

Wp-config.php is the configuration file contains configuration details such as database, settings, authentication keys etc of your WordPress website.

It is located in the root folder of a WordPress file directory.

It does not come in the downloaded WordPress folder but generated during the WordPress installation process.  


Things You Need to do Before Editing wp-config.php

Wp-config.php file contains a lot of important and crucial information.

Therefore the very first thing, I will recommend you is to take – 

  • Either backup of your website’s configuration file or
  • Backup the whole website.

If you won’t take a backup then you might end up making your website inaccessible.

Check out our list of – Best WordPress Backup Plugins you can use to take a backup.


Understanding wp-config.php file

WordPress does not provide wp-config.php file, but it does provide a sample configuration file with name “wp-config-sample.php”.

You can check out the sample how it looks like here.

Wp-config.php configuration file is a well-documented file which is divided into following sections –

  1. Database (MySQL) Settings
  2. Secret keys – Authentication Unique Keys and Salts
  3. WordPress Database Table prefix
  4. For developers: WordPress debugging mode
  5. Absolute path to the WordPress directory
  6. WordPress vars and included files

1. MySQL Database Settings in wp-config.php File

“MySQL Settings” section in the wp-config.php file contains database connection settings of the WordPress which includes MySQL host, database name, database username, and password.

These are the details you are asked to fill when you do the installation of WordPress.

MySQL Database Settings in wp-config.php File

You can easily get the MySQL database and user information via cPanel. And if in case you don’t, then you need to contact your web hosting provider.


2. Secret Keys – Authentication Unique Keys and Salts

WordPress Secret Keys are a collection of variables that are used to improve the security of the WordPress website.

Authentication keys and salts provide encryption for user sessions and cookies generated by WordPress. WordPress generate security keys and salts during installation.

You can also generate WordPress security keys manually.

I will recommend that you should change them at a regular interval of time or at the time of any suspicious activity.

Changing security keys will make all currently logged in users logout from the WordPress site and they need to login again.


3. WordPress Database Table Prefix

What is a Table Prefix?

A table prefix is an entity placed in the front of each WordPress database table.

I will recommend that the default prefix should be changed to something more secure.

For example – “wp_wp123456_”, “tblpfx_” etc.

Changing the table prefix will make your website less vulnerable to hackers.

New WordPress Installation v/s Existing WordPress

  • If you’re about to install a new WordPress. You can set a secure table prefix while installation.
  • But if you’re an existing WordPress, then you can check our article about – How to change the WordPress database prefix?

4. For Developers Only – WordPress Debugging Mode

WordPress Debugging mode setting for a developer –

WP_DEBUG – controls the reporting of notices and errors generated by PHP during code execution. WordPress hides these notices and errors by default and can be displayed by changing the value of WP_DEBUG to true.

define('WP_DEBUG', false);

5. Absolute Path to the WordPress Directory

Absolute paths are used to set up – WordPress vars and included files.

/** Absolute path to the WordPress directory. */

if ( !defined(‘ABSPATH’) )

   define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

/** Sets up WordPress vars and included files. */

require_once(ABSPATH . ‘wp-settings.php’);

Final Words

Now that you know everything about wp-config.php.

You are ready to make the necessary changes to wp-config.php file of your WordPress website.

You can also check our other WordPress tutorial about “How to Safely Add Code Snippets to Functions.Php File in WordPress?”.

You can drop your questions and issues while following the steps above in the comments below.  

Leave a Reply

Your email address will not be published. Required fields are marked *

1.2K views
Share via
Copy link