DEV Community

loading...
Cover image for Create and connect a Siteground PostgreSQL Database

Create and connect a Siteground PostgreSQL Database

logantai24 profile image Logan Tai ・2 min read

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.

Creating Postgresql Database in Siteground

  1. Create a new site in Siteground if haven't done so
  2. Head over to Site Tools, find "PostgreSQL" under "SITE" section
  3. 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/0 into the list of the whitelisted host. Notice adding 0.0.0.0/0 will allow all IPs to connect to your database if your database credentials are leaked.

  4. 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).

  5. 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.

Setup remote connection to the postgresql database

For connecting a postgresql database, you will need to locate the below 5 information:

  1. Hostname/Address
  2. Port
  3. Database Name
  4. Username
  5. Password

Database Name, Username & Password

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.

Port

According to Siteground's help center, 5432 is the default PostgreSql port.

Hostname/Address

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!

Discussion (0)

pic
Editor guide