Q. How do I install PostgreSQL server under Ubuntu Linux?
A. PostgreSQL is an Open Source Software object relational database management system. POSTGRES pioneered many of the object-relational concepts now becoming available in some commercial databases. Traditional relational database management systems (RDBMS) support a data model consisting of a collection of named relations, containing attributes of a specific type. In current commercial systems, possible types include floating point numbers, integers, character strings, money, and dates.
Task: Install PostgreSQL
The best way to install PostgreSQL under Debian or Ubuntu Linux is to use apt-get command
# apt-get install postgresql
OR
$ sudo apt-get install postgresql
Output:
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
openssl postgresql-7.4 postgresql-client postgresql-client-7.4 postgresql-client-common postgresql-common ssl-cert
Suggested packages:
ca-certificates postgresql-doc-7.4
Recommended packages:
postgresql-plpython-7.4 postgresql-plperl-7.4 postgresql-pltcl-7.4
The following NEW packages will be installed
openssl postgresql postgresql-7.4 postgresql-client postgresql-client-7.4 postgresql-client-common postgresql-common
ssl-cert
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 5620kB of archives.
After unpacking 14.3MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get: 1 http://cudlug.cudenver.edu stable/main openssl 0.9.8c-4 [1004kB]
......
........
..
...
Setting up postgresql-7.4 (7.4.16-1) ...
Creating new cluster (configuration: /etc/postgresql/7.4/main, data: /var/lib/postgresql/7.4/main)...
Moving configuration file /var/lib/postgresql/7.4/main/postgresql.conf to /etc/postgresql/7.4/main...
Moving configuration file /var/lib/postgresql/7.4/main/pg_hba.conf to /etc/postgresql/7.4/main...
Moving configuration file /var/lib/postgresql/7.4/main/pg_ident.conf to /etc/postgresql/7.4/main...
Configuring postgresql.conf to use port 5432...
Starting PostgreSQL 7.4 database server: main.
Setting up postgresql-client (7.5.22) ...
Setting up postgresql (7.5.22) ...
Task: Connect to PostgreSQL server
You can login as PostgreSQL superuser, enter command:
$ su - postgres
Now connect to default database called template1:
$ psql template1
Output:
postgres@debian:~$ psql template1 Welcome to psql 7.4.16, the PostgreSQL interactive terminal. Type: \\copyright for distribution terms \\h for help with SQL commands \\? for help on internal slash commands \\g or terminate with semicolon to execute query \\q to quit template1=#
Type \l to list database
Type \q to quit
See also:
🐧 5 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
when t use command:
$ su – postgres
Password:
I don’t know what my password? Can you support me, thank you.
By default there is none
When it asks to enter a password just simply press enter. without typing anything
the default password is not blank -.- this is annoying
when I seting a data base I used command:
/usr/bin/createdb -h localhost -p 5433 -U dellstore
and supposing dellstore is a data base. at once apprience a command :
password:
let’s help me answer why? thanks
After installation and before connecting you can set a password for postgres as follows,
sudo passwd postgres
This command will ask new password directly.