Install postges database ubuntu linux server
Update your package index using
apt
Install the
postgresql
package usingapt
. The package includes the PostgreSQL server and additional tools for managing databases.Start and enable the PostgreSQL service to run automatically at boot.
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl enable postgresql
sudo systemctl start postgresql
Prerequisites
To follow this tutorial, you will need a server running Ubuntu 20.04 or later. This server should have a non-root administrative user and a firewall configured with UFW. You can set this up by following our initial server setup guide for Ubuntu 20.04.
Output
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2025-02-19 12:34:56 UTC; 10s ago
...
PostgreSQL creates a default system user called postgres, which is used to manage the database server. We will switch to this user and create a new database.
sudo -i -u postgres
Now, create a new database called test using the PostgreSQL command-line tool.
createdb test
To verify that the database was created successfully, connect to PostgreSQL and list the databases.
psql
\l
The output should include the newly created test database.
Output
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------+----------+---------+-------+-----------------------
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
test | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
(2 rows)
To exit PostgreSQL, type:
\q
To return to the normal shell session, type:
exit
Teraz je PostgreSQL úspešne nainštalovaný a prvá databáza test vytvorená. Môžete ju začať používať na vývoj alebo testovanie aplikácií.
Komentáre ku článku
Toto je text
sdadad asdas kjasdlP r
Toto je text