Debian 10 Buster
Sponsored Link

PostgreSQL : Install2019/08/07

 
Install PostgreSQL to configure database server.
[1] Install and start PostgreSQL.
root@dlp:~#
apt -y install postgresql
root@dlp:~#
vi /etc/postgresql/11/main/postgresql.conf
# line 59: uncomment and change if you allow accesses from remote hosts

listen_addresses = '
*
'
root@dlp:~#
systemctl restart postgresql

[2] Set PostgreSQL admin user's password and add a user and also add a test database.
# set password

root@dlp:~#
su - postgres

postgres@dlp:~$
psql -c "alter user postgres with password 'password'"

ALTER ROLE
# add DB user [debian] as an example

postgres@dlp:~$
createuser debian
# create a test database (owner is the user above)

postgres@dlp:~$
createdb testdb -O debian
[3] Login as a user just added above and operate DataBase as test operation.
# show Databases

debian@dlp:~$
psql -l

                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 testdb    | debian   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)

# connect to test DB

debian@dlp:~$
psql testdb

psql (11.4 (Debian 11.4-1))
Type "help" for help.

# set password
testdb=# alter user debian with password 'password'; 
ALTER ROLE

# create a test table
testdb=# create table test ( no int,name text ); 
CREATE TABLE

# insert test data
testdb=# insert into test (no,name) values (1,'debian'); 
INSERT 0 1

# show tables
testdb=# select * from test; 
 no |  name
----+--------
  1 | debian
(1 row)

# delete test table
testdb=# drop table test; 
DROP TABLE

# quit
testdb=# \q 

# delete test database

debian@dlp:~$
dropdb testdb
Matched Content