Wp-config.php Database Settings & Other Useful Tricks for WordPress

WP-config.php is the most important file for WordPress Installation. We bring settings of WP-config.php. Some of the settings are not known to us but really important for our blog/website. These settings include simple database settings to protecting our wp-config.php file.

If you had installed the WordPress via Fantastico, you may not be aware about the existence of wp-config.php. The wp-config.php is the most important file in the WordPress. It holds your database information including its password. These file also have so many configuration settings that you never know. Here are some tricks by which you can add functionality to your WordPress by editing wp-config.php file.

By default, there is not wp-config.php file in WordPress setup. However there is wp-config-sample.php to create a wp-config.php file and you can do more with this file to get more from your WordPress copy.

There are 2 ways to create wp-config.php file. One way is to manually create the wp-config.php file and then access your site. Other way is to install a copy & access your site & wait of automated screen to create wp-config.php file.

1.) Database Settings for WordPress for WP-config.php

For Manual Installation you can rename your wp-config-sample.php file t0 wp-config.php and look for the below code.

[php]

// ** MySQL settings – You can get this info from your web host ** //

/** The name of the database for WordPress */

define( ‘DB_NAME’, ‘database_name_here’ );

/** MySQL database username */

define( ‘DB_USER’, ‘username_here’ );

/** MySQL database password */

define( ‘DB_PASSWORD’, ‘password_here’ );

/** MySQL hostname */

define( ‘DB_HOST’, ‘localhost’ );

[/php]

Things between /* */ are comments and are for understanding purpose. You have to enter the database name ‘database_name_here’ for example ‘pp125678database’.

Single inverted Commas (”) are required with database name, username, password & local host. And in the same way you replace ‘username_here’ with your ‘username’, ‘password_here’ with ‘password’ and ‘localhost’ with ‘localhost address’. You will get all this information from your web hosting provider.

[php]
define(‘DB_CHARSET’, ‘utf8’);

define(‘DB_COLLATE’, ”);

[/php]

You would not change these setting 99% times. Only change these values when you are sure that your database is using different charset value. DB_COLLATE valve also must be left blank unless you are not sure that what you are doing.

Now save the file and go on following link to install.

www.example.com/wp-admin/install.php , change example.com with your website address.

You can see more settings here.  If you are getting an error in database connection you can visit this page to resolve this issue.

You can see other setting and can configure your wp-config.php file in WordPress.

2.) Security Keys for Wp-config.php File

WordPress security keys are a set of random variable that improves the encryption of the information stored in the user’s cookies. Prior to WordPress 3.0, you have to install this security keys in your wp-config.php file. In WordPress 3.0 up to 3.5.1, this information is automatically added in wp-config.php file when your configure it as define in step -1 above. Currently there are 8 secret keys and they are:-

[php]

define(‘AUTH_KEY’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_KEY’, ‘put your unique phrase here’);
define(‘LOGGED_IN_KEY’, ‘put your unique phrase here’);
define(‘NONCE_KEY’, ‘put your unique phrase here’);
define(‘AUTH_SALT’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_SALT’, ‘put your unique phrase here’);
define(‘LOGGED_IN_SALT’, ‘put your unique phrase here’);
define(‘NONCE_SALT’, ‘put your unique phrase here’);

[/php]

You can easily get your unique secret keys value by visiting the online generator. Now replace the above code with your unique secret keys and you are done.

3.) Changing Database Prefix in wp-config.php

When you are installing WordPress via automated wizard, one option comes to choose the table prefix. We recommend that you change your database prefix from wp_ to something other. This may add some more work to the hackers, if your site is been attacked.

Table prefix is stored in the wp-config.php file as

[php]

$table_prefix = ‘wp_’;

[/php]

For existing instillation, you have to take the necessary steps before changing the table prefix. You can read the Len Kutchma post on how to change the table prefix in WordPress.

4.) Language Configuration for WordPress Wp-config.php File.

By default WordPress comes with English language but you can change it to your native language also. Please check the official WordPress Codex website to find WordPress in your native language.

You can change the WordPress by defining the following in your Wp-config.php file.

[php]
define(‘WPLANG’, ”);
define(‘LANGDIR’, ”);

[/php]

Now your language translation file (.mo) must be placed in the default location. First is assumed to be wb-content/languages and second are wp-includes/languages. You can also define your own language directory in the above function if you want.

5.) Debugging WordPress with WP-Config.php file

For developers, WordPress has this awesome debugging feature that allows to finding errors. By default, this function is set to false. In the developer mode, you can enable it.

[php]

define(‘WP_DEBUG’, false); // disable debugging mode by default
define(‘WP_DEBUG’, true); // enable debugging mode

[/php]

6.) Increase PHP memory limit in WordPress by wp-config.php file

Sometime you might have seen the fatal error while installing or deleting any plugin.

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes).

You can increase the PHP limit by adding the following code to your wp-config.php file.

[php]

define(‘WP_MEMORY_LIMIT’, ‘128M’);

[/php]

And following to you .htaccess file.

[php]
php_value memory_limit 128M
[/php]

You can change the 128M to 256M also if you still getting the error.

Note: This feature may not work with some web hosts. In this case, you would have to ask them to increase PHP memory.

7.) Secure your WordPress WP-config.php file

As you can see, that wp-config.php file is the most important file. This file must need some security so that other cannot access to the file.

You can add the following code to the .htaccess file to limit the access to wp-config.php file. This code makes your wp-config.php file more secure.

[php]

# protect wpconfig.php

<files wp-config.php>

order allow,deny

deny from all

</files>

[/php]

 

Wp-config.php file settings that you may know

Wp-config.php file settings that you may know


Co-Founder of WebburR.com, Having knowledge of SEO, Coding, Ethical Hacking and WordPress. Launched WebburR.com to enhance user experience.

Comments are closed.