= this will create user "postgres"
Then: sudo passwd postgres
= choose a password
Then switch to postgres user using:
sudo -iu postgres
Then: [postgres]$ initdb -D /var/lib/postgres/data
Then:
systemctl enable postgresql
and
systemctl start postgresql
ThenBecome the postgres user.
sudo -iu postgres
Add a new database user using the createuser command:
[postgres]$ createuser --interactive
Create a new database over which the above user has read/write privileges using the createdb command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add
-O database-username
to the following command):
$ createdb myDatabaseName
Then to connect:
[postgres]$ psql -d myDatabaseName
Some helpful commands:
Get help:
=> \help Connect to a particular database:
=> \c <database> List all users and their permission levels:
=> \du Show summary information about all tables in the current database:
=> \dt Exit/quit the
psql
shell:
=> \q or CTRL+d
sources http://www.postgresqltutorial.com/postgresql-uuid/
Add the UUID plugin:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
Test it with:
SELECT uuid_generate_v1();
Aucun commentaire:
Enregistrer un commentaire