{"id":13868,"date":"2024-05-28T20:15:55","date_gmt":"2024-05-28T17:15:55","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=13868"},"modified":"2024-05-28T20:15:56","modified_gmt":"2024-05-28T17:15:56","slug":"how-to-install-postgresql-psql-on-ubuntu-24-04-lts","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/how-to-install-postgresql-psql-on-ubuntu-24-04-lts\/","title":{"rendered":"How to Install PostgreSQL (psql) on Ubuntu 24.04 LTS"},"content":{"rendered":"\n
PostgreSQL, often referred to as Postgres, is a powerful, open-source object-relational database<\/a> system with a strong reputation for reliability, feature robustness, and performance. In this guide, we will walk you through the steps to install PostgreSQL on Ubuntu 24.04 LTS.<\/p>\n\n\n\n PostgreSQL<\/a> is known for its advanced features like complex queries, foreign keys, triggers, updatable views, transactional integrity, and multi-version concurrency control. It supports a wide range of data types and can be extended by users in many ways, making it an excellent choice for both small and large applications.<\/p>\n\n\n\n Before you start, ensure that you have:<\/p>\n\n\n\n First, update your package index to make sure you have the latest information on the newest versions of packages and their dependencies:<\/p>\n\n\n\n Ubuntu’s default package repository includes PostgreSQL, so you can install it easily using the Once the installation is complete, you can verify that PostgreSQL is installed and running correctly.<\/p>\n\n\n\n You should see output indicating that PostgreSQL is active and running.<\/p>\n\n\n\n By default, PostgreSQL is set up to use the peer authentication method for local connections, meaning it uses the operating system user accounts for authentication.<\/p>\n\n\n\n You will now be logged into the PostgreSQL shell as the Here are some basic commands to get you started with PostgreSQL:<\/p>\n\n\n\n If you need to access your PostgreSQL server remotely, you will need to configure PostgreSQL to listen on all IP addresses and allow connections from remote hosts.<\/p>\n\n\n\n Save and close the file.<\/p>\n\n\n\n Save and close the file.<\/p>\n\n\n\n Congratulations! You have successfully installed and configured PostgreSQL on your Ubuntu 24.04 LTS system. PostgreSQL is now ready to be used for your database management needs, whether for development or production environments. For more detailed information on using PostgreSQL, check out the official PostgreSQL documentation<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":" PostgreSQL, often referred to as Postgres, is a powerful, open-source object-relational database system with a strong reputation for reliability, feature robustness, and performance. In this guide, we will walk you…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,28,16,18],"tags":[180,354,424,433,449,955,531,545,591,598],"yoast_head":"\nWhy PostgreSQL?<\/h3>\n\n\n\n
Prerequisites<\/h3>\n\n\n\n
\n
Step 1: Update Your System<\/h3>\n\n\n\n
$ sudo apt update\n$ sudo apt upgrade -y<\/code><\/pre>\n\n\n\n
Step 2: Install PostgreSQL<\/h3>\n\n\n\n
apt<\/code> package manager.<\/p>\n\n\n\n
\n
$ sudo apt install postgresql postgresql-contrib -y<\/code><\/pre>\n\n\n\n
Step 3: Verify the Installation<\/h3>\n\n\n\n
\n
$ sudo systemctl status postgresql<\/code><\/pre>\n\n\n\n
Step 4: Configure PostgreSQL<\/h3>\n\n\n\n
\n
$ sudo -i -u postgres<\/code><\/pre>\n\n\n\n
\n
$ psql<\/code><\/pre>\n\n\n\n
postgres<\/code> user.<\/p>\n\n\n\n
Step 5: Basic PostgreSQL Commands<\/h3>\n\n\n\n
\n
\\password postgres<\/code><\/pre>\n\n\n\n
\n
CREATE DATABASE mydatabase;<\/code><\/pre>\n\n\n\n
\n
CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypassword';<\/code><\/pre>\n\n\n\n
\n
GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser;<\/code><\/pre>\n\n\n\n
\n
\\l<\/code><\/pre>\n\n\n\n
\n
\\c mydatabase<\/code><\/pre>\n\n\n\n
\n
\\dt<\/code><\/pre>\n\n\n\n
\n
\\q<\/code><\/pre>\n\n\n\n
Step 6: Enable Remote Access to PostgreSQL (Optional)<\/h3>\n\n\n\n
\n
$ sudo nano \/etc\/postgresql\/11\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n
\n
#listen_addresses = 'localhost'<\/code><\/pre>\n\n\n\n
\n
codelisten_addresses = '*'<\/code><\/pre>\n\n\n\n
\n
$ sudo nano \/etc\/postgresql\/11\/main\/pg_hba.conf<\/code><\/pre>\n\n\n\n
\n
host all all 0.0.0.0\/0 md5<\/code><\/pre>\n\n\n\n
\n
$ sudo systemctl restart postgresql<\/code><\/pre>\n\n\n\n
Conclusion<\/h3>\n\n\n\n