Connexion

ShellScript
sudo -u postgres psql

Nouvelle base pour une nouvelle application

ShellScript
postgres=# create database mydb;

postgres=# create user myuser with encrypted password 'mypass';

postgres=# grant all privileges on database mydb to myuser;

\c database

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

ALTER DATABASE mydb OWNER TO myuser;

sources : https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e

Supprimer toutes les tables

ShellScript
DROP SCHEMA public CASCADE; 

CREATE SCHEMA public;

GRANT ALL ON SCHEMA public TO postgres; 

GRANT ALL ON SCHEMA public TO public;

GRANT ALL ON SCHEMA public TO traduser;

Dumper une base

ShellScript
sudo -u postgres pg_dump --column-inserts mydb > mydb_dump.sql

Lancer un fichier

ShellScript
sudo -u postgres psql --file my_dump.sql mydb

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

You might also like