Title: accessing $wpdb from a different WordPress database
Last modified: August 30, 2016

---

# accessing $wpdb from a different WordPress database

 *  [Chris_topher](https://wordpress.org/support/users/chris_topher/)
 * (@chris_topher)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/accessing-wpdb-from-a-different-wordpress-database/)
 * I’m creating a plugin and I need to access an external WordPress database’s `
   $wpdb` to find that database’s prefix. The connection to the external database
   is defined in `$conn` and the connection works. However, I’m not sure what code
   to write in order to get the external database’s prefix. I was hoping something
   like this would work:
    `$db_prefix_conn = $conn->base_prefix;` But that doesn’t
   do anything. Any help is greatly appreciated.

The topic ‘accessing $wpdb from a different WordPress database’ is closed to new
replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [prefix](https://wordpress.org/support/topic-tag/prefix/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 0 replies
 * 1 participant
 * Last reply from: [Chris_topher](https://wordpress.org/support/users/chris_topher/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/accessing-wpdb-from-a-different-wordpress-database/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
