WORDPRESS WP-CONFIG.PHP

The wp-config.php is a fundamental part of your WordPress installation.  It specifies, most importantly, information about how to connect to your WordPress database, which is where most of your content is stored. Without this file, your WordPress installation is an empty shell.

Let's take a look at a the most important parts. You can use an FTP client or the cPanel File Manager to view your wp-config.php file. If you do you'll see the following section pretty close to the top:

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

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

/** MySQL database password */
define('DB_PASSWORD', 'a1S@d3f$');

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

 

The above section is where WordPress specifies the MySQL database, the MySQL username and the MySQL user password (which is different than your cPanel username and your wp-admin username).  When someone clicks to one of your WordPress articles WordPress pulls the images from your media folder, which is usually in your wp-content folder. But it pulls all the text and metadata for your article from the database, using the info specified here in the wp-config.php file.

Note: if your WordPress gives you a database connection error, that often means that the data mentioned above is not correct.

On a cPanel system, you can create the database, user, and password without having to ever log in to the command line. 

If you use Softaculous, then you specify the name of the MySQL database when you install, but it actually creates the database for you and assigns a user and password to it automatically! Done and done.

Tip! You can also use the wp-config.php file to correct a half-changed site URL! If you want to use a new domain name for your site, and make the change in WHM/cPanel before you make the change in the wp-admin area, your site may not work anymore. And you won't even be able to log in to the admin area to fix it, because that area relies on the domain name too. ---  If you have access to the wp-config.php file, however, you can simply add these following lines at the bottom, using your new domain name, and the site will work again. 

define('WP_HOME','http://www.yournewdomainname.com');
define('WP_SITEURL','http://www.yournewdomainname.com');


Note: Be sure to add above the lines  /* That's all, stop editing! Happy blogging. */

  • 44 Users Found This Useful
Was this answer helpful?

Related Articles

How to clean (reinstall) a wordpress site after being hacked

Make a new folder that you will use to store the old site, normally something along the lines...

CloudFlare - What fields do I need to enter in W3TC (W3 Total Cache) settings?

Upon installation of W3 Total Cache, please visit Performance > Extensions and activate...

Using CloudFlare and WordPress: Five Easy First Steps

With tens of millions of sites on the internet using Wordpress, many WordPress sites have decided...

How to force https with WordPress

Unfortunately forcing your WordPress site to use HTTPS is not as simple as updating your...

The Basics of Good Wordpress Security Controls

  Moving beyond the theoretical, we take the concepts presented above and provide a list of...