Should You Upgrade WordPress wp-config.php?

By Posted 2007 Updated   BloggingSecurityWordPress

Whenever a new wordpress version is released, and we upgrade wordpress, there is one file we never upgrade: wp-config.php which has the MySQL database details. Have you ever looked up how this file has changed over the year? Have you ever upgraded wp-config.php?

wp-config.php is a very important file that defines the WordPress configuration settings required to access your MySQL database. The new wordpress download always provides a wp-config-sample.php so that you do not overwrite the precious wp-config.php file by mistake and end up with MySQL database errors. New wordpress users need to fill in the MySQL database details and rename the file to make wordpress work. Though I keep my core wordpress and its plugins updated, I thought what if wp-config.php had undergone a change over these years and had a security hole accessible to hackers.

My wp-config.php File

I realized I have never edited my wp-config.php since I moved from Blogger to WordPress. Here is what my code looks like since WordPress 1.5 a year and a half back (PHP Comments removed)

<?php
define('WP_CACHE', true);
define('DB_NAME', 'putyourdbnamehere');
define('DB_USER', 'usernamehere');
define('DB_PASSWORD', 'yourpasswordhere');
define('DB_HOST', 'localhost');
$table_prefix  = 'wp_';
define ('WPLANG', '');
$server = DB_HOST;
$loginsql = DB_USER;
$passsql = DB_PASSWORD;
$base = DB_NAME;
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>

Latest wp-config.php

Here is what the code in the latest wordpress version 2.3.1 looks like

<?php
define('DB_NAME', 'putyourdbnamehere');
define('DB_USER', 'usernamehere');
define('DB_PASSWORD', 'yourpasswordhere');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
$table_prefix  = 'wp_';
define ('WPLANG', '');
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>

Changes in wp-config.php

As you notice, 2 new tags have been added

define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

And the following have been removed

$server = DB_HOST;
$loginsql = DB_USER;
$passsql = DB_PASSWORD;
$base = DB_NAME;

WP-Cache Manager added this as per comments (but I do not use WP-cache). I do not why it is still persisting.

define('WP_CACHE', true);

Should you upgrade wp-config.php?

Since WordPress Version 2.2, DB_CHARSET was made available to allow designation of the database character set (e.g. tis620 for TIS620 Thai) to be used when defining the MySQL database tables. DB_COLLATE was made available to allow designation of the database collation (i.e. the sort order of the character set).

I checked up more official information about editing wp-config.php, and was lucky I did not upgrade my wp-config.php as they give a warning that if DB_CHARSET and DB_COLLATE do not exist in your wp-config.php file, you should NOT add either definition to your wp-config.php file unless you read and understand Converting Database Character Sets.

After that advice, it seems best to not upgrade my wp-config and let it stay as it is. At least it is working well right now, and not much has changed anyway.


9 comments on “Should You Upgrade WordPress wp-config.php?

  1. Thilak says:

    After reading the title of this post on Google Reader, I though of upgrading. Thank god, I read the complete post.

  2. Manas says:

    You had almost got me to upgrade to wp-config.php. ;)

  3. QuickOnlineTips says:

    I just made “I did not upgrade” into red color. That should help those who skipped the details. :-)

  4. Matt says:

    I’ve upgraded it when I switched to WP 2.3 but I commented out the 2 new tags as they caused the UTF8 characters to display very funky.

  5. topblogposts says:

    I am going to upgrade my wordpress to version 2.3 after that I will upgrade my wp-config file .
    thanks for the informations .

  6. QuickOnlineTips says:

    topblogposts – you are not supposed to upgrade if your wp-config is very old or you will get errors.

  7. Pat Walsh says:

    too late but I did upgrade my wp-config.php wordpress config file and I had to restore. what a pain. Wish I had have read this forum earlier.

    Pat

  8. Malvinder says:

    Dear, the Only Question to you would be where to find the wp-config.php in the dreamhost panel.

    As I want to delete the space in the wp-config.php file due to the feed error ..

    please help me out i have seen all the possible guide on the internet but was not able to find the wp-config.php file.,

    help me urgent

    • QuickOnlineTips says:

      wp-config.php file can be accessed via FTP only in your wordpress installation folder.

Leave a Reply

Your email address will not be published. Required fields are marked *




css.php