Siteground is one of the top WordPress hosting providers, and you could use it for some database hosting too! Sadly there hasn't been much documentation around for setting up PostgreSQL with Siteground (especially for newbies like myself), and Siteground's documentation on PostgreSQL isn't very updated for the new Site Tools.
This article is a straightforward step-by-step guide on setting a PostgreSQL database in Siteground, and finding the needed information to remote connecting it.
- Create a new site in Siteground if haven't done so
- Head over to Site Tools, find "PostgreSQL" under "SITE" section
Since Siteground blocked access to your site's server, you have to whitelist IP addresses first. Go to the REMOTE tab, add your ip address to the Remote Access Host. To make it more convenient, add
0.0.0.0/0into the list of the whitelisted host. Notice adding
0.0.0.0/0will allow all IPs to connect to your database if your database credentials are leaked.
Switch to USERS tab, click "CREATE USER" and a user will be automatically created. If you don't like the default password, click the three dots under action and change the password for this user (and save it somewhere else, you will need it later).
Switch to the DATABASES tab, click "CREATE DATABASE" and an empty postgresql database will be created. Click the Person icon under Actions to grant access to the created user to this database.
That's it for the Siteground part! Consider adding Labels to both the database and user to make things easier to refer to in the future.
For connecting a postgresql database, you will need to locate the below 5 information:
- Database Name
Database Name, Username & Password for this Siteground postgresql database are information you have just created if you have followed along, and these information are always accessible under the "SITE" → "PostgreSQL" section in Site Tools.
According to Siteground's help center, 5432 is the default PostgreSql port.
To locate the hostname of your server/database, head over to your site's "DASHBOARD" via Site Tools. Find "Site IP" under "Site Information" → "IP and Name Servers" section, this IP address is all you need.
You should now be able to connect to your Siteground PostgreSQL database!