Create a connection to another database
To create a new connection add a new connection code to app/etc/local.xml after primary database section.
Check the following example of local.xml:
<?xml version="1.0"?>
<config>
<global>
<install>
<date><![CDATA[]]></date>
</install>
<crypt>
<key><![CDATA[]]></key>
</crypt>
<disable_local_modules>false</disable_local_modules>
<resources>
<db>
<table_prefix><![CDATA[]]></table_prefix>
</db>
<default_setup>
<connection>
<host><![CDATA[host]]></host>
<username><![CDATA[username]]></username>
<password><![CDATA[password]]></password>
<dbname><![CDATA[dbname]]></dbname>
<initStatements><![CDATA[SET NAMES utf8]]></initStatements>
<model><![CDATA[mysql4]]></model>
<type><![CDATA[pdo_mysql]]></type>
<pdoType><![CDATA[]]></pdoType>
<active>1</active>
</connection>
</default_setup>
<!-- START new connection to wordpress database !-->
<wordpress_setup>
<connection>
<host><![CDATA[wordpress_host]]></host>
<username><![CDATA[wordpress_database_username]]></username>
<password><![CDATA[wordpress_database_password]]></password>
<dbname><![CDATA[wordpress_database_name]]></dbname>
<initStatements><![CDATA[SET NAMES utf8]]></initStatements>
<model><![CDATA[mysql4]]></model>
<type><![CDATA[pdo_mysql]]></type>
<pdoType><![CDATA[]]></pdoType>
<active>1</active>
<use>0</use>
</connection>
</wordpress_setup>
<!-- FINISH new connection to wordpress database !-->
</resources>
<session_save><![CDATA[files]]></session_save>
</global>
<admin>
<routers>
<adminhtml>
<args>
<frontName><![CDATA[admin]]></frontName>
</args>
</adminhtml>
</routers>
</admin>
</config>
After changing the local.xml file, you must clear the magento cache.
Was this page helpful?
Your feedback about this content is important.
Let us know what you think.