Ubuntu 安装 PostgreSQL 和 python-psycopg2基础教程(以及错误解决)

Django支持以下四种数据库PostgreSQL(pgql)、SQLite 3、MySQL、Oracle。PostgreSQL 和 MySQL都是最受人关注的开源数据库,MySQL在国内又相对盛行,这和php领域大力推崇lamp不无关系; 关于Mysql和PostgreSQL的对比网上有很多版本,也没必要去比较,不过可以确定的一点是PostgreSQL对Django的 GIS支持更加强大。在Ubuntu 系统下为Python Django安装 PostgreSQL 数据库,还包括pgadmin3 和 python-psycopg2 等。

安装PostgreSQL 数据库

sudo apt-get install postgresql postgresql-client postgresql-contrib

安装过程提示:

The following NEW packages will be installed:
libossp-uuid16 libpq5 postgresql postgresql-8.4 postgresql-client
postgresql-client-8.4 postgresql-client-common postgresql-common
postgresql-contrib postgresql-contrib-8.4
……
Adding user postgres to group ssl-cert
……
Creating new cluster (configuration: /etc/postgresql/8.4/main, data: /var/lib/postgresql/8.4/main)…
Moving configuration file /var/lib/postgresql/8.4/main/postgresql.conf to /etc/postgresql/8.4/main…
Moving configuration file /var/lib/postgresql/8.4/main/pg_hba.conf to /etc/postgresql/8.4/main…
Moving configuration file /var/lib/postgresql/8.4/main/pg_ident.conf to /etc/postgresql/8.4/main…
Configuring postgresql.conf to use port 5432…
……
* Starting PostgreSQL 8.4 database server [ OK ]
Setting up postgresql (8.4.8-0ubuntu0.11.04) …
Setting up postgresql-client (8.4.8-0ubuntu0.11.04) …
Setting up postgresql-contrib-8.4 (8.4.8-0ubuntu0.11.04) …
Setting up postgresql-contrib (8.4.8-0ubuntu0.11.04) …
Processing triggers for libc-bin …

即创建了配置文件的位置为:/etc/postgresql/8.4/main/
可执行程序为:

 sudo /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status}

Read moreUbuntu 安装 PostgreSQL 和 python-psycopg2基础教程(以及错误解决)