How to Edit WP Config File in WordPress ?

In this short article we will go through the steps required to edit wp config file in wordpress. Let’s Start –


1- cPanel Access, this is your web hosting dashboard where your website files are hosted.

2- Website Backup.

3- Basic understanding of php or any other programming language is a plus. If not thats fine.

Video Tutorial

Common use cases for editing this file

1- Updating your database and user details

2- WordPress error establishing database connection


Below, I have shared a screenshot sample of wp-config.php file, that will help you understand what is inside this file or what the contents of this file looks like ?

wp-login file
wp-config.php file
How to edit WordPress wp-config.php file in cPanel
How to edit WordPress wp-config.php file in cPanel

Editing wp-config

Lets, get to the business and start editting our file. At this point, I assume you have your file opened in the editor. Please follow instructions below –

Note: MySQL settings – You can get this info from your cPanel or web developer

1- Code below allows you to change your wordpress websites database to your new database name

define(‘DB_NAME’, ‘myOldDatabaseName‘);

just update the last part, to with the new name-

define(‘DB_NAME’, ‘myNewDatabaseName‘);

and thats it.

2- Similarly change MySQL database username
define(‘DB_USER’, ‘test_user’);

3- Update to the latest MySQL database password
define(‘DB_PASSWORD’, ‘myPassword123’);

4- MySQL hostname (this line and rest of the file stays unchanged)
define(‘DB_HOST’, ‘localhost’);

Hope this helped, please leave your thoughts in comments below.

Default image
Navjot Singh Virk
Navjot is a Hobby Blogger from Ireland and loves to create content to help people. He makes time on weekends to work on this blog. And has a full time position at Workday as Technical Product Manager, which he loves and thrives at. His Skills include in-depth knowledge of SEO, Javascript, Advertising, HTML, Java and Product Management. And his other hobbies include Investing, Gardening and playing Table Tennis.