Table of Contents
How to connect wpDataTables to MySQL, MS SQL and PostgreSQL databases
Say your WordPress site runs on one server, and your company’s stock levels live in an MS SQL database on another, with your customer list in PostgreSQL. You don’t need to copy that data into WordPress. Add each database as a separate connection in wpDataTables, and every table you create can read its data straight from the database you choose.
Which databases can I connect?
You can connect as many MySQL, MS SQL and PostgreSQL databases as you need, on the same server as WordPress or on any other server your site can reach. Each table uses one connection, so different tables on the same page can show data from different databases.
How do I add a separate database connection?
Go to wpDataTables → Settings, open the Separate DB connection tab, fill in the connection details, test them and click Save Changes.
- Open the tab. Go to wpDataTables → Settings and open the Separate DB connection tab.
- Add a connection. Add a new connection and fill in the fields from the table below.
- Test it. Click Test DB settings. wpDataTables tries to log in and tells you whether the connection works.
- Save the settings. Click Save Changes.
| Field | What to enter |
|---|---|
| Connection Name | A name you’ll recognize in the table wizard, for example Stock (MS SQL). |
| Vendor | MySQL, MS SQL or PostgreSQL. |
| Driver | For MS SQL, the driver installed on your server. dblib is selected by default. |
| Name | The name of the database. |
| Host | The address of the database server: a domain name or an IP address. |
| Port | Only if the server doesn’t use the default port: 3306 for MySQL, 1433 for MS SQL, 5432 for PostgreSQL. |
| User and Password | The login of a database user. A user with read-only access is enough for tables you only show. |
| Default Connection | Turn it on for the connection the table wizard should select first. |
Read how to configure the wpDataTables settings for the other settings tabs.

How do I create a table from another database?
Choose the database in the Connection list at the top of the table wizard, then create the table as usual. The connection applies to everything the wizard creates from that point:
- Tables from an SQL query. Click Create a data table linked to an existing data source, choose SQL query and write the query in the language of that database. Read how to create a table from a MySQL query.
- Manual and imported tables. The new database table is created in the chosen database. Read how to create a manual table.
- Query constructor. Generate a query to the MySQL database lists the tables of the chosen database. Read how to build a MySQL query.

What should I remember about database connections?
Add each external MySQL, MS SQL or PostgreSQL database once in wpDataTables → Settings → Separate DB connection, test it with Test DB settings, and mark the one you use most as the Default Connection. Then pick the database in Connection at the top of the table wizard. MS SQL needs SQL Server 2012 or newer and the right PHP driver on your server.
Where can I read more?
These pages show the tables you can build on a connected database: