安装使用 Postgresql 9.1
一,安装1. 下载postgresql-9.1.1-1-linux.bin至/tmp目录
2. # cd /tmp
3. # chmod +x postgresql-9.1.1-1-linux.bin
# ./postgresql-9.1.1-1-linux.bin
第一行是把bin文件改成可执行的文件,第二行执行
4. 安装过程中可设置安装路径、数据库路径和密码、端口
5. 查看是否启动Pgsql:# /etc/init.d/postgresql-9.1 status
启动Pgsql:# /etc/init.d/postgresql-9.1 start
关闭Pgsql:# /etc/init.d/postgresql-9.1 stop
6. 如果需要远程连接管理PgSql,
(1)、修改PostgreSQL配置文件
vi /opt/PostgreSQL/9.1/data/postgresql.conf
listen_addresses='*'
port=5432
(2)、修改PostgreSQL配置文件
vi /opt/PostgreSQL/9.1/data/pg_hba.conf
host all all 0.0.0.0/0 md5
表示允许所有用户访问。
或具体ip : host all all 192.168.1.101/32 md5
(3)、在防火墙中开放5432端口,
查看本机防火墙关于IPTABLES的设置情况 shell> iptables -L -n
如果没有看到开放5432端口,则在文件/etc/sysconfig/iptables中加入:
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT
重启防火墙:shell>service iptables restart
然后可以在windows的pgAdmin软件远程管理Pgsql了
7. Rails应用
$ gem install pg -- --with-pgsql-lib=/opt/PostgreSQL/9.1/lib --with-pg-config=/opt/PostgreSQL/9.1/bin/pg_config
$ rake db:create
问题:
libpq.so.5: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-1.9.2-p180@rails3.1/gems/pg-0.11.0/lib/pg_ext.so
解决:
# cd /etc/ld.so.conf.d
# echo "/opt/PostgreSQL/9.1/lib" >>pgsql.conf
# ldconfig
二、卸载
1. 关闭Pgsql服务器:$ /etc/init.d/postgresql-9.1 stop
2. 删除pgsql安装路径 如:$ rm -rf /opt/PostgreSql
3. 删除pgsql数据库路径 如:$ rm -rf /data/PgSqlData
4. $ rm /etc/init.d/postgresql-9.1
5. $ rm /etc/postgres-reg.ini
页:
[1]