Use Psql in Windows to Connect to an ObjectRocket Instance
Introduction
In this article you will learn how to connect PostgreSQL on Windows to the ObjectRocket instance using the SQL Shell (psql). We’ll cover step by step how to use psql on Windows to connect to an ObjectRocket database.
Prerequisites
You will need to setup an instance of PostgreSQL on your ObjectRocket account.
Install PostgreSQL in Windows
In Windows you can download PostgreSQL from the website. You will have to download and install the version 11 or 12 of PostgreSQL depending on the version you specified on your instance of PostgreSQL in ObjectRocket.
Connect to an ObjectRocket Instance
After you installed PostgreSQL on your local device, open the SQL Shell (psql) to make a connection to your ObjectRocket instance of PostgreSQL. It will open a terminal where you will need to specify the server host name, database name, port, username and password.
Host name
When you open the PostgreSQL shell it will ask for the host name of the server. You can get the host name “ingress” on the “connect” tab.
Database name
The default database that you can connect to on your ObjectRocket instance is postgres
. You can create a new database when you are already connected to the psql. You can connect to the new database using the command \c
.
Port
The port is a 4-digit number and you can find your port number in the “connect” tab beside the ingress host.
Username
Use the username that you used when you created the ObjectRocket instance. You can create multiple usernames in one ObjectRocket instance and specify if it is an admin or not. The default user is postgres
which is an admin user for PostgreSQL.
Password
Use the password you specified for each user when you created the PostgreSQL instance in ObjectRocket.
Example of connection
Now let’s run through an example so you can see how to connect to a PostgreSQL instance in ObjectRocket. For our example, we will use the host domain ingress.w98sujpz.launchpad.objectrocket.cloud
, default database postgres
, port 4144
, the user orkb
and the password.
The following psql
example will show how to connect to the ObjectRocket instance of PostgreSQL using the SQL Shell (psql).
1 2 3 4 5 | Server [localhost]: ingress.w98sujpz.launchpad.objectrocket.cloud DATABASE [postgres]: Port [5432]: 4144 Username [postgres]: orkb Password FOR USER orkb: |
NOTE: The password is not visible when you are typing it as a part of the security, so you should make sure that you are typing the right password.
We are now connected to the ObjectRocket instance of PostgreSQL.
Create database
Now that you have access on the instance, you can now create a database. Using the CREATE DATABASE
statement, you can create a new database for the PostgreSQL.
The following statement will create a new database name objrkt
.
1 | CREATE DATABASE objrkt; |
To connect to the database, use the command \c
plus the name of the database. See the following:
1 | \c objrkt |
To list the database you have on you database, you can use the following:
1 2 3 4 5 6 7 8 9 10 11 | \l List OF DATABASES Name | Owner | Encoding | COLLATE | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- objrkt | orkb | UTF8 | en_US.UTF-8 | en_US.UTF-8 | postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (4 ROWS) |
Conclusion
In this tutorial we’ve walked through how to connect to a PostgreSQL instance on ObjectRocket if you’re working on Windows. We also showed how to create a new database once you’re connected to that instance.
Pilot the ObjectRocket Platform Free!
Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.
Get Started