yum insall python-psycopg2 #安装数据库适配器
yum install postgresql-server #按章postgresql数据库
/etc/init.d/postgresql status //查看数据库状态
service postgresql initdb //初始化数据库 一般路径在/var/lib/pgsql/data
/etc/init.d/postgresql start //启动数据库
安装好后默认有一个postgres数据库,用户名为postgres,密码为空
需要先su为postgres。 #切换用户
psql -d postgres #连接数据库
select * from pg_shadow; #查找用户表
需要想在root用户下也访问数据库。需要修改postgres的配置文件 /var/lib/pgsql/data/pg_hba.conf
local all all ident
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
把上面的ident修改为trust. 并且重启数据库。 service postgresql restart
创建django Porject
django-admin.py startproject mysite
运行web服务器
python manage.py runserver x.x.x.x:8000 #x.x.x.x为你虚拟机的ip地址,不要写成127.0.0.1通过主机访问。 呵呵~
创建数据库
su postgres #切换用户
createdb mydb #创建数据库
psql
\l #查看数据库