Install postgresql9.4 in CentOS 6.7
1. download the correct RPM from the repository RPM listing yum install http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
2. proceed to install and update packages
yum install postgresql94-server postgresql94-contrib service postgresql-9.4 initdb chkconfig postgresql-9.4 on
3. 初始化数据库报错 # service postgresql initdb
4. 初始化方法 # mkdir -p /var/lib/pgsql/data # chown postgres.postgres /var/lib/pgsql/data # su - postgres $ initdb -E UTF-8 -D /var/lib/pgsql/data --locale=en_US.UTF-8 -U postgres -W //初始化数据库
5. 修改/var/lib/pgsql/data/postgresql.conf listen_addresses = '*' //监听所有ip的连接,默认是本机 port = 5432 //这个不开也行,默认就是5432端口
6. 修改/var/lib/pgsql/data/pg_hba.conf
# TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 0.0.0.0/0 md5 //所有IP和用户,密码对都可以连接 # IPv6 local connections: host all all ::1/128 md5
7. 启动并查看 # /etc/init.d/postgresql start //启动 # netstat -tpnl |grep 5432
8. 用postgres用户登录,并改密码
[root@rudder data]# su postgres //切换用户 bash-3.2$ psql -U postgres //连接pgsql server Welcome to psql 8.1.23,the PostgreSQL interactive terminal. Type: copyright for distribution terms h for help with SQL commands ? for help with psql commands g or terminate with semicolon to execute query q to quit postgres=# Alter USER postgres WITH PASSWORD '***密码**'; //添加密码 ALTER ROLE //出现这个才算成功,第一次操作没成功,pgadmin连不上 postgres-# q //退出
9. pgadmin客户端工具连接pgsql serverhttp://www.pgadmin.org/download/windows.php (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|