How to Create PostgreSQL Managed Database at DigitalOcean

Managed Database is a cloud service that provides a database engine. With a managed database, users no longer need to install and configure databases, including monitoring and maintaining server infrastructure.

Managed database services aim to make users, especially developers, focus on application development, without having to be bothered with managing databases.

DigitalOcean provides managed database services that support 3 database engines, namely MySQL, PostgreSQL, and Redis.

*Create a PostgreSQL Managed Database*

1. Click the *Create->Databases* menu 2. *Choose a database engine*, select PostgreSQL 3. *Choose a cluster configuration*, here I use the specifications of 1GB RAM, 1vCPU, 10GB disk, without Standby Nodes. *Standby Nodes* are the nodes that become the backup server, if a failure occurs on the main database server, the database service is switched to the standby node (automatic failover) 4. *Choose a datacenter*, here I use Singapore 5. *Choose a unique database cluster name*, enter a name for the cluster database 6. Finally, click the *Create a Database Cluster* button

Create PostgreSQL database cluster

*Connection to the Database Cluster*

1. *Secure this database cluster*, in the field *Add trusted sources*, enter the name of the droplet, kubernetes cluster, tags, or IP address that is granted access to the database. Here I enter the ubuntu droplet that is in the same region and private network. Then click *Allow these inbound sources only* 2. *Connection details*, displayed connection information to the cluster database, and connections via public and private networks. Click *Continue* 3. *Next steps*, a command is displayed to perform a database migration. Click *Great, I’m done*

Database cluster overview

*Create User and Database*

Create a user and database can be done directly in the tab *Users & Databases*.

*Create User*

1. *Add new user*, enter a new user 2. *Password* is provided automatically

*Create Database*

· *Add new database*, enter a new database name

User & Database

*Connect to Database*

Previously the database cluster was set up so that it could only be accessed by the ubuntu droplet, therefore database access tests were run on that droplet.

Connect to database using psql, install the PostgreSQL client on Ubuntu.


1 apt install postgresql-client -y

Copy the command to connect to the database (flags) shown in the connection details.

Connection details

Testing database access via the public network.


1 PGPASSWORD=cew2dcuz9vnt4kqq psql -U webapp -h -p 25060 -d webapp –set=sslmode=require

Connecting to PostgreSQL database via public network

Testing database access via private network.


1 PGPASSWORD=cew2dcuz9vnt4kqq psql -U webapp -h -p 25060 -d webapp –set=sslmode=require

Connecting to PostgreSQL database via private network

/Get a $100 free credit for every new account creation at DigitalOcean, *register via this link*/

Good luck 🙂

Leave a Reply

Your email address will not be published.