Monthly Archives: October 2014

postgres cheat sheet

change to postgres user and open psql prompt

sudo -u postgres psql postgres
list databases

postgres=# \l
list roles

postgres=# \du
create role

postgres=# CREATE ROLE demorole1 WITH LOGIN ENCRYPTED PASSWORD ‘password1’ CREATEDB;
create role with multiple privileges

postgres=# CREATE ROLE demorole1 WITH LOGIN ENCRYPTED PASSWORD
postgres=# ‘password1’ CREATEDB CREATEROLE REPLICATION SUPERUSER;
alter role

postgres=# ALTER ROLE demorole1 CREATEROLE CREATEDB REPLICATION SUPERUSER;
drop role

postgres=# DROP ROLE demorole1;
create database

postgres=# CREATE DATABASE demodb1 WITH OWNER demorole1 ENCODING ‘UTF8’;
grant privileges to new user

postgres=# GRANT ALL PRIVILEGES ON DATABASE demodb1 TO demorole1;
drop database

postgres=# DROP DATABASE demodb1;
connect to database

postgres=# \c
list tables in connected database

postgres=# \dt
list columns on table

postgres=# \d backup database

$ pg_dump >

dpkg: error processing mysql-server-5.5 (–configure):

If you trying install mysql on fresh Debian VPS (OpenVZ template):

Stopping MySQL database server: mysqld.
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 146: logger: command not found
ATTENTION: An error has occured. More info is in the syslog!
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 236: logger: command not found
dpkg: error processing mysql-server-5.5 (–configure):
subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.

Quick fix:

apt-get install bsdutils

also you can get such errors:

dpkg: error processing mysql-server (–configure):
dependency problems – leaving unconfigured
Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)