TIP to alternate WordPress database config for local

You can make an adjustment to your wp-config for alternating between local and production WordPress database.

if ( file_exists( dirname( __FILE__ ) . '/wp-local-config.php' ) ) {
 include dirname( __FILE__ ) . '/wp-local-config.php';
} else {
 define('DB_NAME', 'livedb_name');
 define('DB_USER', 'livedb_user');
 define('DB_PASSWORD', 'livedb_pwd');
 define('DB_HOST', 'livedb_hostname');
 $table_prefix  = 'wp_';
}

Change the WP_DEBUG line in wp-config.php to

if ( !defined('WP_DEBUG') )
 define('WP_DEBUG', false);

In your DocumentRoot create wp-local-config.php

<?php
define('DB_NAME', 'localdb_name');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost' );
$table_prefix  = 'wp_';
define('WP_LOCAL_DEV', true ); 
define('WP_DEBUG', true);
define('SAVEQUERIES', false);
define('WP_CACHE', false);
define('JETPACK_DEV_DEBUG', true);

Leave a reply:

Your email address will not be published.

Site Footer