PostgreSQL

aptitude install postgresql-8.4

Table Stuff

Show schemas.

\dn

Show tables in current database.

\dt

Show layout of $table.

\d $table

Output

Run a query:

select page, username from arthur_log where username <> '' and page = 'login' order by id desc limit 750;

Output of the next query will be written to xxx.txt:

\o xxx.txt

User Stuff

:!: STICK TO LOWERCASE :!:

Become root, then postgres, then start psql.

$ su -
$ su - postgres
$ psql

Create a user, create a database, give privileges to this DB to user, quit.

# CREATE USER tom WITH PASSWORD 'myPassword';
# CREATE DATABASE jerry;
# GRANT ALL PRIVILEGES ON DATABASE jerry TO tom;
# \q

Become root, back up, then edit access config file.

$ logout
$ cd /etc/postgresql/8.4/main
$ cp pg_hba.conf pg_hba.conf.old
$ vim pg_hba.conf

Anywhere (preferably at the top), add user and allow him to access from localhost.

...
# local      DATABASE  USER  METHOD  [OPTIONS]
local jerry tom md5
...

Restart daemon.

$ /etc/init.d/postgresql restart

Source: http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/

 
postgresql.txt · Last modified: 2012/02/08 21:24 by volker
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki