If you have installed WordPress, you may see that there is a file called wp-config.php. The name of the file actually gives away it’s purpose. This file is meant to be a configuration file for your WordPress installation. In it, you will find the database connection details and various other configuration options. While it may be a scary looking file and changes made here could break your site, we will go into what some of these options are and why you would want to change them.
How Do I Edit the wp-config.php File?
Usually you may want to edit this file by downloading it to your local computer. Then once the changes are made, reuploading to the server. But you can also edit this file within cPanel.
- Log into your cPanel.
- Once logged in, navigate to find the File Manager.
- From the File Manager, click through the folders to find where your WordPress is installed.
- Inside that folder you should see a wp-config.php file. Right click on that file and choose Edit.
- This will open up a text editor within cPanel where you can make direct edits to the file.
Changing Database Login Credentials
One of the most common reasons you would want to edit the wp-config.php file would be to change the database login information. Situations where you would need to change these would include any hosting migrations, or even regular password changes made. Here’s what each of those options mean and what you can change them to.
- The DB_NAME variable is used to define the current database name for WordPress. If the database name for your WordPress installation changes at some point. You would want to modify this option to let WordPress know. Modify the second text, the one after ‘DB_NAME’.
- DB_USER is used to specify the user when connecting to the database. Usually this would change per database, but if needed you can also just create this user in the database as well. If changed, you can set that here by changing that second text.
- DB_PASSWORD is the password for the user to login to the database. This would be the most common of the options to change, as the password may change the most frequently. Make sure that this password is accurate to the one that works for the above mentioned DB_USER.
- The DB_HOST is used to specify the server where WordPress will try to connect to when looking for the database. By default, localhost means that the Database is on the same server as the website. If you have your database on another server, you will input that server address or host-name here.
- DB_CHARSET determines the character set that will be used for creating database tables for WordPress. You would mainly want to change this if you need a particular character set for a different language. For example, if you were using the Greek Alphabet in your database, you would want the DB_CHARSET to be set to iso-8859-7 . Though usually the default value for this can remain.
- As it states, the DB_COLLATE affects how WordPress databases Collate. Basically the Collation of a table affects how it is sorted based on lettering. This can remain the default, unless you are needing this to specifically be changed.
There are a bunch of other things that can be changed in the wp-config.php file that affect your WordPress installation. WordPress also has a handy guide on what the possible changes can be. Though we can assist as well if needed.
- Installing WordPress Using Softaculous – Here is a guide that can assist with the installation of WordPress, easily through Softaculous Apps Installer.
- Enable HTTPS In WordPress – Quick article that describes the process of enabling HTTPS for your WordPress installation.
- WordPress Codex > Editing wp-config.php – WordPress site that shows possible edits that can be made to the wp-config.php file.