Home / mysql

mysql

How to access another Database in WordPress

wpdb is the class that helps you to manipulate the database in WordPress. But you can not access it directly, you have to use the global object $wpdb to manipulate the database. The Database configuration is stored in wp-config.php during installation process. Highlighted like this

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');