How to create a database in Azure Database for PostgreSQL flexible server

How to create a database in Azure Database for PostgreSQL flexible server

In this article, we will discuss the quick steps to create a database in Azure Database for PostgreSQL flexible server.

How to create a database in Azure Database for PostgreSQL flexible server

Follow the below steps to create the database.

  1. Log in to the Azure Portal.
  2. Navigate to the Azure Database for PostgreSQL flexible server that you have created. If you have not yet created one, you can create a flexible server for your Azure Database for PostgreSQL now.
create a database in PostgreSQL in Azure

3. Click on the Databases link from the left navigation and then click on the + Add button.

Create a database in Azure Database for PostgreSQL flexible server

4. On the Create Database window, Provide a name for your Database and then click on the Save button to create the database.

Create a database in Azure Database for PostgreSQL

5. Now, it will take a few seconds to create the Database and you will see a message that the database has been created successfully. To cross-check, click on the Databases link from the left navigation and you will see the newly created database.

Create a database in Azure Database for PostgreSQL single server

Create a database in Azure Database for PostgreSQL flexible server using Azure CLI

You can also create the database using Azure CLI Follow the below steps.

  1. Navigate to the Azure Database for PostgreSQL flexible server and click on the Databases link from the left navigation and cross-check the available databases.
  2. Click on the Cloud Shell icon from the top right of the Azure Portal then choose the Bash option.
Create a database in Azure Database for PostgreSQL flexible server using Azure CLI

3. Run the below command and make sure to change the host and the username as per yours.

psql --host=tsinfops.postgres.database.azure.com --port=5432 --username=tsinfouser --dbname=postgres

After the modification you can copy paste the above coomand on the terminal and hit Enter. Now it will ask to enter password for user. Enter the Password and hit the enter key. You will get the below output.

bijay [ ~ ]$ psql --host=tsinfops.postgres.database.azure.com --port=5432 --username=tsinfouser --dbname=postgres
Password for user tsinfouser: 
psql (14.5)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=> 

4. Now Write the below command to create the database.

Create Database tsinfonew;

Press the enter key. You will get the output like below

Create a database in Azure Database for PostgreSQL flexible server Azure CLI

Now to cross check , if the database is created or not, Navigate to the Azure Database for PostgreSQL flexible server –> Click on the Databases link from the left side and refresh the page then you will see the new database got created successfully.

how to create a database in Azure Database for PostgreSQL flexible server using Azure CLI

You may also like following the below articles

Wrapping Up

In this article, we have discussed two simple approaches to create database in Azure Database for PostgreSQL flexible server. Thanks for reading this article !!!