How to Edit WordPress's wp-config.php File Using cPanel

From all the files available in the WordPress directory, the wp-config.php file plays an important role, which is the file responsible for the connection between the website and its database.

Whenever you get an error related to the database connection, you need to edit this file. Just like the .htaccess file, you can easily find it in the file manager.

But most of the people get confused and don’t able to locate the wp-config.php file. You should also know that there are some authentications keys present in this file.

In the last couple of years, many web hosting companies have started offering access to cPanel which makes everything easier.

In this tutorial, you will learn the proper use of cPanel and how you can edit the wp-config.php file without breaking your WordPress website.

Now you may be wondering as if something technical is there. Well, if you’re a non-technical person, follow this tutorial.

For a techie person, it’s a piece of cake.

Why Would You Want to Edit this File

As I have mentioned earlier, this file is responsible for connecting your website’s data to its database. When you install WordPress, it generates the database itself.

But it wasn’t the same a few years ago. The users had to create the database separately.

And to connect the WordPress installation with the database created using cPanel, the database credentials should be the same in the WordPress directory.

And this is controlled by the wp-config.php file.

Now you may ask as if what’s the need to know it when everything is automated these days. It’s because whenever you receive any error while migrating your website or restoring it from its backup, you have to edit this file.

One of the most common errors is “Error Establishing a Database Connection” which can only be solved if you match the database credentials.

Follow these steps to edit it.

Step 1

First of all, you have to log into cPanel of your web hosting and open the file manager
. You can find it in the files’ section.

If you’re using Bluehost, the icons will be totally different but the options will be quite similar. Even the Siteground users may find it a little different.

But don’t worry, you can easily find the file manager. At some web hostings, it’s named only as Files.

Step 2

Click on the icon to open it.
Now if you’re having a single website on your web hosting, you will see all the files and folders of your website.

But if you host multiple websites, you may have to open the folder in which your website has been placed.

Once you open the directory where all the files and folders of the website are present, you have to search for the wp-config.php file.

Step 3

It’s not a big deal.

Just scroll down and you can find this file
. Don’t confuse it with wp-config-sample.php file.

Step 4

To edit it, right-click on the file and you can see many options. Click on the edit option
. You can also use the edit option available in the main navigation menu of cPanel.

Step 5

Once you click to edit, you will see a popup. You will be recommended to backup this file and this is the most important thing to do.

So before you edit it, you have to download it on your computer.

Now, click on the Edit button and a tab will open for you where you can see all the codes of this file. If you’re familiar with WordPress, you can easily recognize the database name, database password, hostname etc.

You will also see some codes which have been added by the plugins you use. If you use any caching plugin, there are chances that you may see a few codes.

Step 6

Once you add any external code or edit the existing code, you have to save this file.

To do so, click on the save changes button present at the top-right corner of the screen. Now go back to the root directory and refresh it.

Check your website. If everything is good, congrats, you have successfully edited the wp-config.php file.

Every now and then people scare others by telling the stories of how they broke their websites while editing the files. Don’t listen to them.

It’s really important that you experience yourself. You can’t rely on others forever. The basics of cPanel can be learned on your own.

Google is there to help you. And the tutorials like this can definitely give you the information you need.

I Hope You Didn’t Find it as Hard as People Say

Did you follow the above-mentioned steps? It’s really important that you take the backup of that file. I would suggest you to backup your whole website.

If you’re not sure about it, you can use any backup plugin.

And if you’re not familiar with any code written in the wp-config.php file, you shouldn’t change it. If you’re asked to copy and paste any code, it’s simple.


Check out the top 3 WordPress hosting services:

Was this article helpful?