Skip to content

Instantly share code, notes, and snippets.

@cukabeka
Created December 12, 2013 22:32
Show Gist options
  • Save cukabeka/7936754 to your computer and use it in GitHub Desktop.
Save cukabeka/7936754 to your computer and use it in GitHub Desktop.
If we want to use different database credentials for the local development server and the online production or staging server, we can modify the database settings in the wp_config file http://blog.g-design.net/post/60019471157/managing-and-deploying-wordpress-with-git
if ($_SERVER['REMOTE_ADDR']=='127.0.0.1') {
define('WP_ENV', 'development');
} else {
define('WP_ENV', 'production');
}
// MySQL settings - You can get this info from your web host //
if (WP_ENV == 'development') {
define('DB_NAME', 'mydb-dev');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
} else {
define('DB_NAME', 'mydb-prod');
define('DB_USER', 'username');
define('DB_PASSWORD', 'pasdword');
define('DB_HOST', 'mysql.mysite.com');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment