Tsohost Knowledge Base

Understanding the wp-config.php file

Modified Sunday 20th April, 2014 at 09:13

Was this helpful?

The wp-config.php file contains the database details for your WordPress site. They will look a little something like this;

define(‘DB_NAME’, ‘databasename’) ;          // The name of the database
define(‘DB_USER’, ‘databaseuser’) ;          // The name of the database user
define(‘DB_PASSWORD’, ‘databasepassword’) ;          // The database password
define(‘DB_HOST’, ‘localhost’) ;           // This will usually be set to localhost as default and will not usually need to be changed.

If you ever see an Error establishing a database connection warning on your site, this will usually mean that either the DB_NAME, DB_USER, DB_PASSWORD or DB_HOST has been entered incorrectly in the wp-config.php file.

Secret Keys

The wp-config.php file also contains secret keys (as seen below) These are designed to make the WordPress installation more secure.

define(‘AUTH_KEY’, ‘xxxxxxxxxx’) ;
define(‘SECURE_AUTH_KEY’, ‘xxxxxxxxxx’) ;
define(‘LOGGED_IN_KEY’, ‘xxxxxxxxxx’) ;
define(‘NONCE_KEY’, ‘xxxxxxxxxx’) ;
define(‘AUTH_SALT’, ‘xxxxxxxxxx’) ;
define(‘SECURE_AUTH_SALT’, ‘xxxxxxxxxx’) ;
define(‘LOGGED_IN_SALT’, ‘xxxxxxxxxx’) ;
define(‘NONCE_SALT’, ‘xxxxxxxxxx’) ;

You can generate secret keys here: api.wordpress.org/secret-key/1.1/

Database Charset

The database charset defines the character set that is applied to the WordPress installation.
define(‘DB_CHARSET’, ‘utf8′);

UTF-8 supports all languages so does not really ever need to be changed.


Defining the website URL in the wp-config.php file

You can define the site URL and home URL in the wp-config.php file like so;

define( ‘WP_SITEURL’, ‘http://mydomain.co.uk’ );

define( ‘WP_HOME’, ‘http://mydomain.co.uk’ );



Enabling WordPress Multi-site

To enable the WordPress multi-site feature you just need to add the following to the wp-config.php file;

define( ‘WP_ALLOW_MULTISITE’, true );


Enable Debug Mode

To enable the WordPress debug mode you just need to add the following to the wp-config.php file;

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_LOG’, true );

define( ‘WP_DEBUG_DISPLAY’, true );


Enable caching

To enable caching you just need to add the following to the wp-config.php file;

define( ‘WP_CACHE’, true );



Database optimisation and repair tool

To make use of the WordPress database optimisation and repair tool you just need to add the following to the wp-config.php file;

define( ‘WP_ALLOW_Repair’, true );

You can run the repair.php script by typing the following in the web browser address bar: http://mydomain.co.uk/wp-admin/maint/repair.php


Force SSL

Here you can secure the login and admin page by forcing SSL

define( ‘FORCE_SSL_LOGIN’, true );

define( ‘FORCE_SSL_ADMIN’, true );


WordPresswp-config.phpsecret keysdatabase charsetWPMU

Still can't find what you're looking for?

That's not a problem. Our 24/7 customer support team are friendly and waiting to help answer your questions. The easiest way to get in touch is to raise a support ticket; simply click the button below.

Open Support Ticket