postgresql 9.2.6学习记录
Postgres 9.2.6 源码安装
[root@nagios tmp]# wgethttp://ftp.postgresql.org/pub/source/v9.2.6/postgresql-9.2.6.tar.gz
[root@nagios tmp]# tar zxvfpostgresql-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]# gmakeinstall
[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 ~]# chownpostgres.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 ~]# chownpostgres.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]# cpcontrib/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]# chownpostgres.postgres /usr/local/pgsql/.psql_history
[root@nagios postgresql-9.2.6]# servicepostgresql 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)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。