Name | Last modified | Size | Description | |
---|---|---|---|---|
Parent Directory | - | |||
my_pgserver/ | 2020-01-22 14:21 | - | ||
my_pgserver.log | 2020-01-22 14:21 | 1.5K | ||
cd my_project_dir
mkdir my_pgserver
module load postgresql/11.1
initdb -D my_pgserver
pg_ctl -D my_pgserver -l my_pgserver.log start
method 1:
logon to postgres db (it is a PostgreSQL built-in db) through commandline interactive utility 'psql', and use 'CREATE DATABASE' sql command in psql shell, and you then can use '\c' sql command to change the current database to work on:
psql postgres
postgres=# CREATE DATABASE testdb;
CREATE DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------+----------+-------------+-------------+---------------------
postgres | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/yshen16 +
| | | | | yshen16=CTc/yshen16
template1 | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/yshen16 +
| | | | | yshen16=CTc/yshen16
testdb | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
postgres=# \c testdb
You are now connected to database "testdb" as user "yshen16".
testdb=#
method 2:
use 'createdb' commandline tool to create database, the following command is to create a db called 'testdb2':
createdb testdb2
psql testdb2
testdb2=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------+----------+-------------+-------------+---------------------
postgres | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/yshen16 +
| | | | | yshen16=CTc/yshen16
template1 | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/yshen16 +
| | | | | yshen16=CTc/yshen16
testdb | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
testdb2 | yshen16 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
testdb=# \q
[yshen16@scc1 my_pgserver]$
if done from parent directory:
pg_ctl -D my_pgserver stop
Or done from any directory:
pg_ctl -D my_project_dir/my_pgserver stop