微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql 9.2.6学习记录

Postgres 9.2.6 源码安装


yum install zlib-devel


[root@nagios tmp]# wget http://ftp.postgresql.org/pub/source/v9.2.6/postgresql-9.2.6.tar.gz

[root@nagios tmp]# tar zxvf postgresql-9.2.6.tar.gz

[root@nagios tmp]# cd postgresql-9.2.6

[root@nagios postgresql-9.2.6]#./configure -without-readline

[root@nagios postgresql-9.2.6]# gmake

[root@nagios postgresql-9.2.6]# gmake install


[root@nagios ~]# vi .bash_profile

PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin


[root@nagios ~]# source .bash_profile


[root@nagios ~]# adduser postgres


[root@nagios ~]# vi /etc/passwd

postgres:x:501:501::/home/postgres:/bin/bash

改为:postgres:x:501:501::/usr/local/pgsql:/bin/bash


[root@nagios ~]# cp .bash_profile /usr/local/pgsql/

[root@nagios ~]# chown postgres.postgres /usr/local/pgsql/.bash_profile

[root@nagios ~]# cd /home


[root@nagios home]# rm -fr postgres/


[root@nagios ~]# mkdir /usr/local/pgsql/data

[root@nagios ~]# chown postgres.postgres /usr/local/pgsql/data/


[root@nagios ~]# su - postgres

-bash-4.1$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/

-bash-4.1$ exit


[root@nagios tmp]# cd postgresql-9.2.6

[root@nagios postgresql-9.2.6]# cp contrib/start-scripts/linux /etc/init.d/postgresql

[root@nagios postgresql-9.2.6]# chmod +x /etc/init.d/postgresql

[root@nagios postgresql-9.2.6]#chkconfig --add postgresql

[root@nagios postgresql-9.2.6]#chkconfig postgresql on

[root@nagios postgresql-9.2.6]# touch /usr/local/pgsql/.psql_history

[root@nagios postgresql-9.2.6]# chown postgres.postgres /usr/local/pgsql/.psql_history

[root@nagios postgresql-9.2.6]# service postgresql start


切换到postgres用户使用


[root@nagios data]# su � postgres

-bash-4.1$ createdb test


-bash-4.1$ psql test

psql (9.2.6)

Type "help" for help.


test=#


直接在root用户

[root@nagios ~]# psql -U postgres

psql (9.2.6)

Type "help" for help.


postgres=#


postgres=# \c test

You are Now connected to database"test" as user "postgres".

test=#


test=# create table test(id int);

CREATE TABLE

test=# \dt

List of relations

Schema | Name | Type | Owner

--------+------+-------+----------

public | test | table | postgres

(1 row)

原文地址:https://www.jb51.cc/postgresql/195776.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐