Need to update your CMS database details?

  • Pin It
  • Pin It

Ever needed to update the database name, user or password for your content management system? The most common time I find I need to do this is when I'm moving a website from one server to another. Sometimes you can replicate the database details exactly, sometimes you can't.

I work predominately with Drupal, Magento and Wordpress content management systems. So where do you find the configuration for the database in these systems?

Drupal

File location from document root: /sites/default/settings.php

Section to edit:

$databases = array (
   default' =>
   array (
      'default' =>
      array (
         'database' => 'name',
         'username' => 'username',
         'password' => 'pwd,
         'host' => 'localhost',
         'port' => '',
         'driver' => 'mysql',
         'prefix' => '',
      ),
   ),
); 

Just edit the section between the apostrophe's on the right hand side of the =>. These should be your database name, your database username and your database password.

Magento

File location from document root: /app/etc/local.xml

Section to edit:

<connection>
<host><![CDATA[hostname]]></host>
<username><![CDATA[DB username]]></username>
<password><![CDATA[DB pwd]]></password>
<dbname><![CDATA[DB name]]></dbname>
<active>1</active>
</connection>

Only edit the sections in [square brackets], most specifically username, pwd and name. As the XML suggests, these are the database username, database password and database name.

Wordpress

File location from document root: /wp-config.php

Section to edit:

define('DB_NAME', 'name');

define('DB_USER', 'username');

define('DB_PASSWORD', 'pwd');

Again, just edit the sections between the apostrophe's on the right hand side to change the database name, username and password.

Apply your changes

Once you are done any changes, upload your new settings file to the appropriate location on the server and unless there is something else on the server impacting your website, you should be good to go.

Note: While these changes are pretty easy, a knowledge of FTP and basic understanding of PHP (or XML for Magento) is recommended. Not sure about doing it yourself? Contact us for pricing to do this for you!