690 shaares
3 liens privés
3 liens privés
2 résultats
taggé
psql
Pense-bête
psql -p 5555 -h 10.0.10.2 -U <user> -d <database
Create user
create database mydb;
create user myuser with encrypted password 'mypass';
grant all privileges on database mydb to myuser;
List databases
\list or \l : list all databases
\c dbname or connect dbname : connect to database
\dt : list all tables in the current database
\d+ <table> : describe table
Size of database
SELECT pg_size_pretty(pg_database_size('db'));
Notes postgre :
Find the file pg_hba.conf - it may be located, for example in /etc/postgresql-9.1/pg_hba.conf.or ./data/pg_hba.conf
Back it up
cp pg_hba.conf pg_hba.conf-backup
Authorize local user to connect directly place the following line (as either the first uncommented line, or as the only one):
local all all trust
Restart database
Connect to postgres schema : (you can now connect as any user). Connect as the superuser postgres (note, the superuser name may be different in your installation. In some systems it is called pgsql, for example.)
psql -U postgres
#Note for AXA : psql -U aopuser postgres
#Note for HPA : psql -U hpa -p hpadb
Reset password ('replace my_user_name with postgres since you are resetting postgres user)
ALTER USER my_user_name with password 'my_secure_password';
Restore the old pg_hba.conf as it is very dangerous to keep around, restart?