Ubuntu 16.04
Sponsored Link

PostgreSQL : Install
2016/09/06
 
Install PostgreSQL to configure database server.
[1] Install and start PostgreSQL.
root@dlp:~#
apt-get -y install postgresql
root@dlp:~#
vi /etc/postgresql/9.5/main/postgresql.conf
# line 59: uncomment and change if 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 "ubuntu" as an example

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

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

ubuntu@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    | ubuntu   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)

# connect to test DB

ubuntu@dlp:~$
psql testdb

psql (9.5.4)
Type "help" for help.
# set password

testdb=#
alter user ubuntu 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,'ubuntu');

INSERT 0 1
# show tables

testdb=#
select * from test;
 no |  name
----+--------
  1 | ubuntu
(1 row)
# delete test table

testdb=#
drop table test;

DROP TABLE
# quit

testdb=#
\q
# delete test database

ubuntu@dlp:~$
dropdb testdb
Matched Content
 
Tweet