After the default installation has been created postgres system user
$ sudo -iu postgres # Or su - postgres for root
Initialization data directory
[postgres]$ initdb --locale=zh_CN.UTF-8 -E UTF8 -D /var/lib/postgres/data
Exit this user, start the service postgresql.service
$ createuser --interactive
Create a database
$ createdb myDatabaseName
-d myDatabaseName psql # View all databases \ L # switch databases \ c <Database> # list all users and permissions \ du # lists all the tables in the current database \ dt
/var/lib/postgres/data/postgresql.conf listen_addresses = 'localhost,my_local_ip_address'
journalctl -u postgresql.service
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1'; DROP DATABASE template1;
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
[postgres]$ createdb blog
233