CentOS下安装PostgreSQL<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--># yum install postgresql postgresql-libs postgresql-server[root@dev ~]# service postgresql status
postmaster is stopped
[root@dev ~]# service postgresql start
Initializing database: [ OK ]
Starting postgresql service: [ OK ]
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->[root@dev ~]# chkconfig postgresql on
[root@dev ~]# chkconfig --list postgresql
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->[root@dev ~]# vim /var/lib/pgsql/data/pg_hba.conf
# "local" is for Unix domain socket connections only
#local all all ident sameuser
local all all trust
# IPv4 local connections:
#host all all 127.0.0.1/32 ident sameuser
host all all 127.0.0.1/32 md5
host all all 192.168.28.3
/32 md5 #必须有后面那个,那个是掩码,否则总报pg_hba.conf语法错
[root@dev ~]# su - postgres
-bash-3.2$ pg_ctl reload
postmaster signaled
[root@dev ~]# vim /var/lib/pgsql/data/postgresql.conf
listen_addresses ="*"
[root@dev ~]# su - postgres
-bash-3.2$ pg_ctl reload
postmaster signaled
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--># psql -l 列出所有数据库 # psql
=> l 列出所有数据库
=> c cake 连接到cake数据库
=> dt 列出所有tables
=> d shift 查看shift表结构
=> di 列出所有indexes
=> d shift_pkey 列出所有index: shift_pkey
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->1 import java.sql.Connection;
2 import java.sql.DriverManager;
3 import java.sql.ResultSet;
4 import java.sql.Statement;
5
6 publicclass PostgresqlTest {
7
8 /**
9 * @param args
10 */
11 publicstaticvoid main(String[] args) {
12 try {
13 Class.forName("org.postgresql.Driver").newInstance();
14 String connectUrl ="jdbc:postgresql://192.168.250.231:5432/poem";
15 Connection conn = DriverManager.getConnection(connectUrl,
16 "poem", "poem");
17 Statement st = conn.createStatement();
18 String sql ="select 1;";
19 ResultSet rs = st.executeQuery(sql);
20 while (rs.next()) {
21 System.out.println(rs.getInt(1));
22 }
23 rs.close();
24 st.close();
25 conn.close();
26 } catch (Exception e) {
27 e.printStackTrace();
28 }
29 }
30
31 }
32
PostgreSQL 的详细介绍:请点这里
PostgreSQL 的下载地址:请点这里PostgreSQL缓存详述 http://www.linuxidc.com/Linux/2013-07/87778.htmWindows平台编译 PostgreSQL http://www.linuxidc.com/Linux/2013-05/85114.htmUbuntu下LAPP(Linux+Apache+PostgreSQL+PHP)环境的配置与安装 http://www.linuxidc.com/Linux/2013-04/83564.htmUbuntu上的phppgAdmin安装及配置 http://www.linuxidc.com/Linux/2011-08/40520.htm更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14Bandwidthd+PostgreSQL数据库配置笔记Ubuntu 下修改MySQL的字符为UTF-8相关资讯 PostgreSQL安装
- Linux CentOS 7 安装PostgreSQL 9. (今 08:48)
- Ubuntu 14.04安装PostgreSQL 9.2 (09/16/2015 08:49:17)
- Linux安装PostgreSQL 9.4 (05/19/2015 08:54:24)
| - 在CentOS 6.5上编译安装PostgreSQL (06月13日)
- CentOS 6.5下PostgreSQL 9.4.3安装 (07/25/2015 09:27:10)
- Mac OSX下编译安装PostgreSQL (12/26/2014 19:27:33)
|
本文评论 查看全部评论 (0)