You can easily set up another $wpdb
object to access your other database.
$mydb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
var_dump($mydb);
That, of course, uses the default connection credentials but if you defined different constants and used those, is should work just fine.
If this other database is not a WordPress database, you won’t have some of the functionality offered by the wpdb
class but the basics should work if you write the SQL.
Related Posts:
- Please explain how WordPress works with MySQL character set and collation at a low level
- Connect to database using wordpress wp-config file
- Custom DB_COLLATE (collation) value not working on fresh install?
- Why can’t I swap a DB in a WP install? [closed]
- Can I have multiple database users within WordPress?
- Error establishing a database connection on Installation
- Moving WP from local server to live, error establishing a db connection
- Connect to a remote database for wordpress in my own hosting server
- Switching Databases in LocalHost
- Localhost to Staging to Development Dynamic WP-CONFIG
- How to share plugin created database tables between two WordPress sites
- Problem migrating to localhost
- Is my way to change WordPress server is correct?
- how to encyrpt DB_PASSWORD in wp-config
- Getting WordPress to work inside a rails 3 application
- Can two domains use the same database?
- WordPress keeps redirecting to localhost
- How to re-connect WP files in lampp/htdocs to new SQL database to recover site under development
- Duplicate database to roll back theme & content changes
- Confused over wp-config.php and ‘database user + database password + name’
- Cloned site not connecting to database – MAMP
- execute custom function on database connection error
- Does WordPress Support Using Named Pipes on the Windows Operating System?
- I have include wp-config, should I add global $wpdb also?
- Can’t Install WordPress (local) Failed to open file wp-includes/wp-db.php
- Issue “Error establishing a database connection” problem.
- /var/run/mysqld/mysqld.sock
- DB access blocked when initializing WP externally
- How to use remote db tables in current config? [duplicate]
- Multiple Address In WP-Option Value
- ERROR: “Table Prefix” must not be empty
- Can I connect WordPress website with an external database?
- wp-config was suddenly updated
- Oracle SQL query for Date format
- Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)
- Can I have multiple primary keys in a single table?
- get_results using wpdb
- Database connection close
- How to create bulk page and content? [closed]
- Importing posts from old website to new conflicting post ID’s?
- Transient RSS feeds in wp_options not removed automatically?
- Best way to move live site local
- The revisions table in my database is at 70% capacity and growing. What should I do?
- WordPress for a very large website
- Database location in WordPress
- Bad Request (Invalid Hostname) on working server, database problem
- WooCommerce with thousands of products – site is very slow – optimize db queries? [closed]
- WP_list_table bulk_action get edit and delete
- Cloning and syncing a WordPress website
- How to execute mulitple statement SQL queries using $wpdb->query?
- Store and Encrypt Contact Form 7 Submissions in Database? [closed]
- WordPress database growing dramatically in size despite adding no new content
- Clean database from unused tables
- How wordpress accesses its own database
- Migrating database / content of non-CMS site to WordPress
- Should I remove transients from the wp_options table?
- Delete all post meta except featured image Using SQL
- Show last modified date of database
- What generates these very slow postmeta queries? [closed]
- How to migrate a website based on a custom database to wordpress?
- How to scan barcode and store data into a database [closed]
- Fetching values from database for select box
- fastest replacement DB
- Connection refused on locahost after importing database?
- When to use custom DB tables or add_option?
- Have working sql query… trying to adjust it to use $wpdb
- Best host for running large mem and processor intensive WordPress sites?
- creating new field on mysql
- Does WordPress store the username as a primary key in the database?
- Strange characters added to the database
- Database Update Required – Update from command-line
- After database migration, theme mods don’t show [closed]
- SQL query to set posts in bulk based on the post content
- Automate WordPress website setup with prefilled data
- Custom search query by category id
- Website displays old version of page
- Image link issues after importing a database backup to my local web server
- multiple wordpress installs w/shared user database but separate content databases
- Updating seperate database when post attachment is changed
- add featured image dialog box disappear
- Displaying table data on a page
- WordPress Database – wp_usermeta and the correct number of session_tokens rows
- How to get a list of articles related to a particular category from my other WordPress website?
- /wp-admin not accessible after migrating to local host (no plugin issue)
- set_transient fails if the value has more than 60.000 characters
- A WP dev site that displays content from a live site’s database but cannot write to wp_posts?
- Is there a way for two deferent themes to consume two different DB on a same WP instance?
- How do I update a WordPress wp_postmeta meta_value that contains many options
- How can I get $wpdb to show MySQL warnings?
- About wp database hooks (error establishing connection)
- Database for JQuery Autocomplete field
- I changed the password for the database user of my website, updated wp-config.php and wordpress asks to be reinstalled
- Create Tables in WordPress
- WordPress Failed to Login (DB Error)
- Share WordPress Database
- Saving data to database and exporting to excel
- Site does not work right, pages not showing up, even for root admin
- How do you build a database-centric site in WP?
- WordPress: Interact with Database Query Data and Login
- Getting an error when trying to migrate to DV server from Grid with Media Temple [closed]