Posts

Showing posts with the label postgresql

Things to to after install postgresql in linux

After you have done  >> sudo apt-get install postgresql You're open to these things. You have to know that the system must have at least one db that named of you. You need to create that. You can, but it need to do this first Edit pg_hba.conf (locate on /etc/postgresql/ /main/pg_hba.conf Add 2 lines local all all trust host all all 127.0.0.1/32 md5 then restart postgresql service Login to postgresql >> sudo -u postgres psql template1 psql> create user " " with password ' '; psql> alter user " " with superuser; psql>\q >> createdb " " -E UTF8 -O " " That's it. :)

Tiny thing but Cool command for psql

Let's get in psql interactive by >> psql Yes, If you wanna see all yours db. psql>> \l Select db psql>> \c you will get in selected db, then >> \d    # to display all tables

Basic with Postgresql

For psql command line, We'll start with >>> psql Create User psql::CREATE USER joe; psql::ALTER ROLE joe PASSWORD 'secret_password'; Or psql::CREATE USER username WITH PASSWORD 'xxxxx'; Or Create an account where the user can create db; psql::CREATE USER username WITH PASSWORD 'xxxxx' CREATEDB; Give him a right on superuser psql::ALTER ROLE joe WITH CREATEDB; psql::ALTER ROLE joe WITH SUPERUSER; Create Database psql::CREATE DATEBASE mydb; Or psql::CREATE DATABASE dbname OWNER rolename; Grant all available privileges to user psql::GRANT ALL PRIVILEGES ON mydb TO joe; psql::GRANT admins TO joe;

TIP for setup psycopg2 for mac/linux

If something like 'cannot find pg_config' , we should add /path/to/postgres/x.x/bin to PATH environment. That's all for this post.

The Story from Proteus's Productivity seeker

Proper install guide I try to install psycopg2 (2.4.1 bcoz 2.4.2 does not work with django 1.3) on Ubuntu Natty today and got ImportError: can't import mx.DateTime module . Hmm... weird. I googled around and found a sequence of command to do a proper installation of psycopg2. $ sudo apt-get build-dep python-psycopg2 $ virtualenv ENV $ source ENV/bin/activate $ easy_install psycopg2 $ easy_install egenix-mx-base ref: http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/ Damn mx and psycopg2==2.4.1 The sequence of commands above did not fix my ImportError: can't import mx.DateTime module . I wasted a day searching until i found its defect on psycopg2 issue tracker . In sum, if you try $ ls /usr/include/python2.6/ | grep mx and you found that you have mx folder there, you're screwed. Psycopg2 will try to use this damn mx instead of default datetime package and that will prevent you from installing psycop...