apt-get -y install postgresql postgresql-contrib
\list
\dt *
\d
\connect db_production
psql -U deploy -d db_production
ALTER DATABASE db_production OWNER TO deploy;
GRANT ALL PRIVILEGES ON DATABASE db_production to deploy;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO deploy;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO deploy;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO deploy;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO deploy;
sudo -u postgres createuser --superuser admin
psql -U postgres
\du
sudo -u postgres createdb -T template1 db_development
sudo -u postgres psql template1 -c 'create extension if not exists "hstore"'
dropdb 'db_production'
sudo vim /etc/postgresql/9.3/main/pg_hba.conf
local all postgres peer
to
local all postgres trust
sudo service postgresql restart
su – postgres
psql
ALTER USER postgress with password 'password-new';
\q
create role deploy with createdb login password 'xxx';
\du
sudo -u postgres createdb -T template1 db_production
psql -U postgres
psql -d db -U user -W
ALTER USER user with password 'password-new';
sudo -u postgres psql
create user username with password 'password';
alter role username superuser createrole createdb replication;
create database projectname_production owner username;