How to install PostgreSQL on Ubuntu 14.04?
PostgreSQL is a well-known and highly effective open-source relational database management system. It is frequently used to manage and store massive volumes of data.
Steps to Install PostgreSQL on Ubuntu 14.04
Let’s quickly look at the steps for installing PostgreSQL on Ubuntu 14.04.
Step 1: Update Your Ubuntu System
Before installing any new software, it is recommended that you update your system. It assures that you have the latest security updates and bug patches. To begin, open a terminal window and enter the following command:
sudo apt-get update
It will update the package repository of your Ubuntu system.
Step 2: Install PostgreSQL
After your Ubuntu system has been updated, you can install PostgreSQL. To execute this, type the following command into the terminal window:
sudo apt-get install postgresql
It will install PostgreSQL as well as other necessary programs.
Step 3: Access PostgreSQL
After installation, the default user account, ‘Postgres,’ can be used to access PostgreSQL. You may use the subsequent command to connect to the PostgreSQL database as the ‘Postgres’ user:
sudo -i -u postgres
It will give you access to the PostgreSQL command prompt.
Step 4: Create a New PostgreSQL User
Although you may operate your PostgreSQL database using the default ‘Postgres user account,’ establishing a separate user account with limited access is usually recommended. Follow the steps shared below to create a new PostgreSQL user:
- Log in to the PostgreSQL command prompt using the ‘Postgres’ user account, as shown in Step 3.
- Enter the subsequent command to create a new user account: create user –interactive
- Your new user account’s name will be requested. Submit a username of your choice and press Enter. You will be asked whether the new user should be a superuser. Enter ‘n’ to create a user account with limited privileges.
A new user account will be created.
Step 5: Create a New PostgreSQL Database
After creating a new PostgreSQL user account, you can create a new database for that user. To create a new PostgreSQL database, follow the steps below:
- Log in to the PostgreSQL command prompt using the ‘Postgres’ user account, as shown in Step 3.
- Enter the subsequent command to create a new database: createdb database. Substitute ‘database’ with the database name you want to create.
The new database will be created.
Step 6: Connect to the PostgreSQL Database
To connect to the newly created PostgreSQL database using the new user account, follow the steps below:
- Log out of the PostgreSQL command prompt using the following command: exit
- Log in to the PostgreSQL database using the new user account: psql -d my database -U my user. Substitute ‘database’ with the name of the database you created in Step 5 and ‘user’ with the user account name you created in Step 4.
- The password for your new account will be prompted for you to enter. Enter the password and press Enter.
Using the new user account, you will now be connected to the PostgreSQL database.
Bottom Line
PostgreSQL is a strong, open-source database management system. It enables users to manage and store massive amounts of data efficiently and safely. It is easy to install and use on Ubuntu 14.04. Follow the instructions above to install PostgreSQL on your Ubuntu system.