Setting an external database for WordPress from wp_config file

admin

Administrator
Staff member
<strong>Problem:</strong>

How to use an external database, that is not located in localhost, by setting the WordPress configuration in the file <em>wp_config</em>.

So, all WordPress files (wp_content, wp_admin, ...) are in <em>Local computer A</em>, and the database is in <em>Server B</em>.

Can this be done ?, how would the settings be ?

<strong>What I have tried:</strong>

Code:
define('DB_HOST', 'example');
define('DB_HOST', 'example.com');
define('DB_HOST', 'http://example.com');
define('DB_HOST', 'example.com:22');

<strong>Notes:</strong>

<ul>
<li>The server is using MySQL on Linux.</li>
<li>When I change the configuration, to use a local database, it works perfect. So it is not WordPress, is the connection setting.</li>
<li>username, password, and database name (DB_NAME, DB_USER, DB_PASSWORD) are correct. </li>
</ul>

<strong>Current error:</strong>

<blockquote>
Error establishing a database connection
</blockquote>

<strong>Related links:</strong>

<a href="http://codex.wordpress.org/Editing_wp-config.php" rel="nofollow">http://codex.wordpress.org/Editing_wp-config.php</a>

<a href="http://wordpress.org/support/topic/connect-local-wordpress-site-to-remote-database" rel="nofollow">http://wordpress.org/support/topic/connect-local-wordpress-site-to-remote-database</a>

<a href="http://digwp.com/2010/08/pimp-your-wp-config-php/" rel="nofollow">http://digwp.com/2010/08/pimp-your-wp-config-php/</a>