ITPub博客

首页 > 应用开发 > IT综合 > Centos 6.5 下安装postgres 9.3.5

Centos 6.5 下安装postgres 9.3.5

原创 IT综合 作者:victor1010 时间:2014-11-18 16:02:09 1 删除 编辑


gunzip postgresql-9.3.5.tar.gz
tar xf postgresql-9.3.5.tar


./configure
gmake
su
gmake install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test




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


PGDATA=/usr/local/pgsql/data
export PGDATA


************************************
groupadd postgres
useradd -g postgres postgres


passwd postgres


gunzip postgresql-9.3.5.tar.gz
tar xf postgresql-9.3.5.tar
./configure
yum install gcc
yum install readline
yum -y install -y readline-devel
yum install zlib-devel
gmake 
gmake install
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres


/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >strtup.log &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test


************************************
[root@myLinux002 postgresql-9.3.5]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... no
checking for cc... no
configure: error: in `/home/postgres/postgresql-9.3.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.




[root@myLinux002 postgresql-9.3.5]# yum install gcc
Loaded plugins: security
base                                                                                                         | 3.7 kB     00:00     
extras                                                                                                       | 3.3 kB     00:00     
extras/primary_db                                                                                            |  19 kB     00:00     
openlogic                                                                                                    | 1.3 kB     00:00     
updates                                                                                                      | 3.4 kB     00:00     
updates/primary_db                                                                                           | 5.4 MB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: cpp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-4.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-4.el6.x86_64
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


====================================================================================================================================
 Package                         Arch                         Version                              Repository                  Size
====================================================================================================================================
Installing:
 gcc                             x86_64                       4.4.7-4.el6                          base                        10 M
Installing for dependencies:
 cloog-ppl                       x86_64                       0.15.7-1.2.el6                       base                        93 k
 cpp                             x86_64                       4.4.7-4.el6                          base                       3.7 M
 mpfr                            x86_64                       2.4.1-6.el6                          base                       157 k
 ppl                             x86_64                       0.10.2-11.el6                        base                       1.3 M


Transaction Summary
====================================================================================================================================
Install       5 Package(s)


Total download size: 15 M
Installed size: 33 M
Is this ok [y/N]: 


Is this ok [y/N]: y
Downloading Packages:
(1/5): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm                                                                   |  93 kB     00:00     
(2/5): cpp-4.4.7-4.el6.x86_64.rpm                                                                            | 3.7 MB     00:00     
(3/5): gcc-4.4.7-4.el6.x86_64.rpm                                                                            |  10 MB     00:00     
(4/5): mpfr-2.4.1-6.el6.x86_64.rpm                                                                           | 157 kB     00:00     
(5/5): ppl-0.10.2-11.el6.x86_64.rpm                                                                          | 1.3 MB     00:00     
------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                16 MB/s |  15 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mpfr-2.4.1-6.el6.x86_64                                                                                          1/5 
  Installing : cpp-4.4.7-4.el6.x86_64                                                                                           2/5 
  Installing : ppl-0.10.2-11.el6.x86_64                                                                                         3/5 
  Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                                                                                  4/5 
  Installing : gcc-4.4.7-4.el6.x86_64                                                                                           5/5 
  Verifying  : gcc-4.4.7-4.el6.x86_64                                                                                           1/5 
  Verifying  : ppl-0.10.2-11.el6.x86_64                                                                                         2/5 
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                                                                                  3/5 
  Verifying  : mpfr-2.4.1-6.el6.x86_64                                                                                          4/5 
  Verifying  : cpp-4.4.7-4.el6.x86_64                                                                                           5/5 


Installed:
  gcc.x86_64 0:4.4.7-4.el6                                                                                                          


Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6     cpp.x86_64 0:4.4.7-4.el6     mpfr.x86_64 0:2.4.1-6.el6     ppl.x86_64 0:0.10.2-11.el6    


Complete!
[root@myLinux002 postgresql-9.3.5]# 




[root@myLinux002 postgresql-9.3.5]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... no
checking whether gcc supports -funroll-loops... yes
checking whether gcc supports -ftree-vectorize... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with Kerberos 5 support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking whether to build with SELinux support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.




检查系统是否安装 readline 包


[root@myLinux002 postgresql-9.3.5]# rpm -qa | grep readline
readline-6.0-4.el6.x86_64
说明系统已经安装了 readline包。




通过 yum 搜索相关的readline 包


root@myLinux002 postgresql-9.3.5]# yum search readline
Loaded plugins: security
====================================================== N/S Matched: readline =======================================================
compat-readline5-devel.i686 : Files needed to develop programs which use the readline library
compat-readline5-devel.x86_64 : Files needed to develop programs which use the readline library
compat-readline5-static.x86_64 : Static libraries for the readline library
libreadline-java-javadoc.x86_64 : Javadoc for libreadline-java
mingw32-readline.noarch : MinGW port of readline for editing typed command lines
readline-devel.i686 : Files needed to develop programs which use the readline library
readline-devel.x86_64 : Files needed to develop programs which use the readline library
readline-static.x86_64 : Static libraries for the readline library
compat-readline5.i686 : A library for editing typed command lines
compat-readline5.x86_64 : A library for editing typed command lines
libreadline-java.x86_64 : Java wrapper for the EditLine library
perl-Term-UI.x86_64 : Term::ReadLine UI made easy
readline.i686 : A library for editing typed command lines
readline.x86_64 : A library for editing typed command lines


  Name and summary matches only, use "search all" for everything.
[root@myLinux002 postgresql-9.3.5]# 




yum install readline


[root@myLinux002 postgresql-9.3.5]# yum install readline
Loaded plugins: security
Setting up Install Process
Package readline-6.0-4.el6.x86_64 already installed and latest version
Nothing to do




[root@myLinux002 postgresql-9.3.5]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... no
checking whether gcc supports -funroll-loops... yes
checking whether gcc supports -ftree-vectorize... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with Kerberos 5 support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking whether to build with SELinux support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.
[root@myLinux002 postgresql-9.3.5]# 


[root@myLinux002 postgresql-9.3.5]#   yum -y install -y readline-devel
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package readline-devel.x86_64 0:6.0-4.el6 will be installed
--> Processing Dependency: ncurses-devel for package: readline-devel-6.0-4.el6.x86_64
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.7-3.20090208.el6 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


====================================================================================================================================
 Package                           Arch                      Version                                  Repository               Size
====================================================================================================================================
Installing:
 readline-devel                    x86_64                    6.0-4.el6                                base                    134 k
Installing for dependencies:
 ncurses-devel                     x86_64                    5.7-3.20090208.el6                       base                    642 k


Transaction Summary
====================================================================================================================================
Install       2 Package(s)


Total download size: 776 k
Installed size: 2.0 M
Downloading Packages:
(1/2): ncurses-devel-5.7-3.20090208.el6.x86_64.rpm                                                           | 642 kB     00:00     
(2/2): readline-devel-6.0-4.el6.x86_64.rpm                                                                   | 134 kB     00:00     
------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                               7.3 MB/s | 776 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ncurses-devel-5.7-3.20090208.el6.x86_64                                                                          1/2 
  Installing : readline-devel-6.0-4.el6.x86_64                                                                                  2/2 
  Verifying  : readline-devel-6.0-4.el6.x86_64                                                                                  1/2 
  Verifying  : ncurses-devel-5.7-3.20090208.el6.x86_64                                                                          2/2 


Installed:
  readline-devel.x86_64 0:6.0-4.el6                                                                                                 


Dependency Installed:
  ncurses-devel.x86_64 0:5.7-3.20090208.el6                                                                                         


Complete!
[root@myLinux002 postgresql-9.3.5]# 


**********
[root@myLinux002 postgresql-9.3.5]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... no
checking whether gcc supports -funroll-loops... yes
checking whether gcc supports -ftree-vectorize... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with Kerberos 5 support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking whether to build with SELinux support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... -lreadline
checking for inflate in -lz... no
configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.
[root@myLinux002 postgresql-9.3.5]# 




********************
[root@myLinux002 postgresql-9.3.5]# .configure
-bash: .configure: command not found
[root@myLinux002 postgresql-9.3.5]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... no
checking whether gcc supports -funroll-loops... yes
checking whether gcc supports -ftree-vectorize... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with Kerberos 5 support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking whether to build with SELinux support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... -lreadline
checking for inflate in -lz... yes
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking crypt.h usability... yes
checking crypt.h presence... yes
checking for crypt.h... yes
checking dld.h usability... no
checking dld.h presence... no
checking for dld.h... no
checking fp_class.h usability... no
checking fp_class.h presence... no
checking for fp_class.h... no
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking ieeefp.h usability... no
checking ieeefp.h presence... no
checking for ieeefp.h... no
checking ifaddrs.h usability... yes
checking ifaddrs.h presence... yes
checking for ifaddrs.h... yes
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking poll.h usability... yes
checking poll.h presence... yes
checking for poll.h... yes
checking pwd.h usability... yes
checking pwd.h presence... yes
checking for pwd.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking sys/pstat.h usability... no
checking sys/pstat.h presence... no
checking for sys/pstat.h... no
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/sem.h usability... yes
checking sys/sem.h presence... yes
checking for sys/sem.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/sockio.h usability... no
checking sys/sockio.h presence... no
checking for sys/sockio.h... no
checking sys/tas.h usability... no
checking sys/tas.h presence... no
checking for sys/tas.h... no
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/un.h usability... yes
checking sys/un.h presence... yes
checking for sys/un.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking ucred.h usability... no
checking ucred.h presence... no
checking for ucred.h... no
checking utime.h usability... yes
checking utime.h presence... yes
checking for utime.h... yes
checking wchar.h usability... yes
checking wchar.h presence... yes
checking for wchar.h... yes
checking wctype.h usability... yes
checking wctype.h presence... yes
checking for wctype.h... yes
checking for net/if.h... yes
checking for sys/ucred.h... no
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for netinet/tcp.h... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking readline/history.h usability... yes
checking readline/history.h presence... yes
checking for readline/history.h... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking whether byte ordering is bigendian... no
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for quiet inline (no complaint if unreferenced)... yes
checking for preprocessor stringizing operator... yes
checking for flexible array members... yes
checking for signed types... yes
checking for working volatile... yes
checking for __func__... yes
checking for _Static_assert... no
checking for __builtin_types_compatible_p... yes
checking for __builtin_constant_p... yes
checking for __builtin_unreachable... yes
checking for __VA_ARGS__... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct tm.tm_zone... yes
checking for tzname... yes
checking for union semun... no
checking for struct sockaddr_un... yes
checking for struct sockaddr_storage... yes
checking for struct sockaddr_storage.ss_family... yes
checking for struct sockaddr_storage.__ss_family... no
checking for struct sockaddr_storage.ss_len... no
checking for struct sockaddr_storage.__ss_len... no
checking for struct sockaddr.sa_len... no
checking for struct addrinfo... yes
checking for intptr_t... yes
checking for uintptr_t... yes
checking for long long int... yes
checking for locale_t... yes
checking for struct cmsgcred... no
checking for struct option... yes
checking for z_streamp... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of off_t... 8
checking for int timezone... yes
checking types of arguments for accept()... int, int, struct sockaddr *, socklen_t *
checking whether gettimeofday takes only one argument... no
checking for cbrt... yes
checking for dlopen... yes
checking for fdatasync... yes
checking for getifaddrs... yes
checking for getpeerucred... no
checking for getrlimit... yes
checking for mbstowcs_l... no
checking for memmove... yes
checking for poll... yes
checking for pstat... no
checking for readlink... yes
checking for setproctitle... no
checking for setsid... yes
checking for sigprocmask... yes
checking for symlink... yes
checking for sync_file_range... yes
checking for towlower... yes
checking for utime... yes
checking for utimes... yes
checking for wcstombs... yes
checking for wcstombs_l... no
checking for fseeko... yes
checking for _LARGEFILE_SOURCE value needed for large files... no
checking for posix_fadvise... yes
checking whether posix_fadvise is declared... yes
checking whether fdatasync is declared... yes
checking whether strlcat is declared... no
checking whether strlcpy is declared... no
checking whether F_FULLFSYNC is declared... no
checking for struct sockaddr_in6... yes
checking for PS_STRINGS... no
checking for snprintf... yes
checking for vsnprintf... yes
checking whether snprintf is declared... yes
checking whether vsnprintf is declared... yes
checking for isinf... yes
checking for crypt... yes
checking for fls... no
checking for getopt... yes
checking for getrusage... yes
checking for inet_aton... yes
checking for mkdtemp... yes
checking for random... yes
checking for rint... yes
checking for srandom... yes
checking for strerror... yes
checking for strlcat... no
checking for strlcpy... no
checking for unsetenv... yes
checking for getpeereid... no
checking for getaddrinfo... yes
checking for getopt_long... yes
checking for sigsetjmp... yes
checking whether sys_siglist is declared... yes
checking for syslog... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for opterr... yes
checking for optreset... no
checking for strtoll... yes
checking for strtoull... yes
checking for builtin locking functions... yes
checking for rl_completion_append_character... yes
checking for rl_completion_matches... yes
checking for rl_filename_completion_function... yes
checking for append_history... yes
checking for history_truncate_file... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking whether pthreads work with -pthreads... no
checking whether pthreads work with -mthreads... no
checking for the pthreads library -lpthread... yes
checking whether pthreads work with --thread-safe... no
checking whether pthreads work with -mt... no
checking for the pthreads library -lpthreadGC2... no
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for strerror_r... yes
checking for getpwuid_r... yes
checking for gethostbyname_r... yes
checking whether getpwuid_r takes a fifth argument... yes
checking whether strerror_r returns int... no
checking test program... ok
checking whether long int is 64 bits... yes
checking size of void *... 8
checking size of size_t... 8
checking size of long... 8
checking whether to build with float4 passed by value... yes
checking whether to build with float8 passed by value... yes
checking alignment of short... 2
checking alignment of int... 4
checking alignment of long... 8
checking alignment of double... 8
checking for int8... no
checking for uint8... no
checking for int64... no
checking for uint64... no
checking for sig_atomic_t... yes
checking for POSIX signal interface... yes
checking for working memcmp... yes
checking for onsgmls... no
checking for nsgmls... no
checking for openjade... no
checking for jade... no
checking for DocBook V4.2... no
checking for DocBook stylesheets... no
checking for collateindex.pl... no
checking for xsltproc... xsltproc
checking for osx... no
checking for sgml2xml... no
checking for sx... no
checking thread safety of required library functions... yes
checking whether gcc supports -Wl,--as-needed... yes
configure: using compiler=gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
configure: using CFLAGS=-O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv
configure: using CPPFLAGS= -D_GNU_SOURCE 
configure: using LDFLAGS=  -Wl,--as-needed
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking src/backend/port/sysv_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/unix_latch.c to src/backend/port/pg_latch.c
config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
[root@myLinux002 postgresql-9.3.5]# 




[root@myLinux002 pgsql]# pwd
/usr/local/pgsql
[root@myLinux002 pgsql]# ls
bin  include  lib  share
[root@myLinux002 pgsql]# mkdir /usr/local/pgsql/data
[root@myLinux002 pgsql]# ls
bin  data  include  lib  share
[root@myLinux002 pgsql]# chown postgres /usr/local/pgsql/data
[root@myLinux002 pgsql]# ls -lt
total 20
drwxr-xr-x. 2 postgres root 4096 Nov  5 08:48 data
drwxr-xr-x. 4 root     root 4096 Nov  5 08:44 lib
drwxr-xr-x. 6 root     root 4096 Nov  5 08:44 share
drwxr-xr-x. 2 root     root 4096 Nov  5 08:44 bin
drwxr-xr-x. 6 root     root 4096 Nov  5 08:43 include


[postgres@myLinux002 bin]$ pwd
/usr/local/pgsql/bin
[postgres@myLinux002 bin]$ ls
clusterdb   createuser  dropuser  pg_basebackup   pg_ctl      pg_isready      pg_restore  psql
createdb    dropdb      ecpg      pg_config       pg_dump     pg_receivexlog  postgres    reindexdb
createlang  droplang    initdb    pg_controldata  pg_dumpall  pg_resetxlog    postmaster  vacuumdb
[postgres@myLinux002 bin]$ initdb -D /usr/local/pgsql/data
-bash: initdb: command not found
[postgres@myLinux002 bin]$ ./initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.


The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".


Data page checksums are disabled.


fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok


WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.


Success. You can now start the database server using:


    ./postgres -D /usr/local/pgsql/data
or
    ./pg_ctl -D /usr/local/pgsql/data -l logfile start


[postgres@myLinux002 bin]$ 


[postgres@myLinux002 bin]$ ./postgres -D /usr/local/pgsql/data >logfile 2>&1 &
[1] 25633
[postgres@myLinux002 bin]$ -bash: logfile: Permission denied


[1]+  Exit 1                  ./postgres -D /usr/local/pgsql/data > logfile 2>&1
[postgres@myLinux002 bin]$ ./createdb test
createdb: could not connect to database template1: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[postgres@myLinux002 bin]$ psql
-bash: psql: command not found
[postgres@myLinux002 bin]$ ./psql
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[postgres@myLinux002 bin]$ ps -ef |grep post
root      4792     1  0 05:15 ?        00:00:00 /usr/libexec/postfix/master
postfix   4801  4792  0 05:15 ?        00:00:00 qmgr -l -t fifo -u
root     12883  5099  0 07:39 ?        00:00:00 sshd: postgres [priv]
postgres 12888 12883  0 07:39 ?        00:00:01 sshd: postgres@notty
postgres 12913 12888  0 07:40 ?        00:00:00 /usr/libexec/openssh/sftp-server
root     13366  5099  0 08:11 ?        00:00:00 sshd: postgres [priv]
postgres 13370 13366  0 08:12 ?        00:00:00 sshd: postgres@pts/2
postgres 13371 13370  0 08:12 pts/2    00:00:00 -bash
postfix  16314  4792  0 08:36 ?        00:00:00 pickup -l -t fifo -u
root     25563 13400  0 08:50 pts/2    00:00:00 su - postgres
postgres 25564 25563  0 08:50 pts/2    00:00:00 -bash
postgres 25647 25564  1 08:59 pts/2    00:00:00 ps -ef
postgres 25648 25564  0 08:59 pts/2    00:00:00 grep post
[postgres@myLinux002 bin]$ ls
clusterdb   createuser  dropuser  pg_basebackup   pg_ctl      pg_isready      pg_restore  psql
createdb    dropdb      ecpg      pg_config       pg_dump     pg_receivexlog  postgres    reindexdb
createlang  droplang    initdb    pg_controldata  pg_dumpall  pg_resetxlog    postmaster  vacuumdb
[postgres@myLinux002 bin]$ 




# .bash_profile


# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


# User specific environment and startup programs


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




export PATH


PGDATA=/usr/local/pgsql/data
export PGDATA


~
~
~
~
~
~
~
~
~
~
~
~
".bash_profile" 17L, 243C written
[postgres@myLinux002 ~]$ exit
logout


Last login: Wed Nov  5 11:42:52 2014 from 114.250.209.87
[postgres@myLinux002 ~]$ pg_ctl
pg_ctl: no operation specified
Try "pg_ctl --help" for more information.
[postgres@myLinux002 ~]$ pg_ctl status
pg_ctl: server is running (PID: 26187)
/usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data"
[postgres@myLinux002 ~]$ pg_ctl stop
waiting for server to shut down..... done
server stopped
[postgres@myLinux002 ~]$ ps -ef |grep postgres
root     26259  5099  0 11:42 ?        00:00:00 sshd: postgres [priv]
postgres 26263 26259  0 11:42 ?        00:00:00 sshd: postgres@pts/2
postgres 26264 26263  0 11:42 pts/2    00:00:00 -bash
root     26421  5099  0 11:59 ?        00:00:00 sshd: postgres [priv]
postgres 26425 26421  0 11:59 ?        00:00:00 sshd: postgres@pts/1
postgres 26426 26425  0 11:59 pts/1    00:00:00 -bash
postgres 26485 26426 15 12:01 pts/1    00:00:00 ps -ef
postgres 26486 26426  0 12:01 pts/1    00:00:00 grep postgres
[postgres@myLinux002 ~]$ pg_ctl start
server starting
[postgres@myLinux002 ~]$ LOG:  database system was shut down at 2014-11-05 12:00:59 UTC
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started


[postgres@myLinux002 ~]$ ps -ef |grep post
root      4792     1  0 05:15 ?        00:00:00 /usr/libexec/postfix/master
postfix   4801  4792  0 05:15 ?        00:00:00 qmgr -l -t fifo -u
root     26259  5099  0 11:42 ?        00:00:00 sshd: postgres [priv]
postgres 26263 26259  0 11:42 ?        00:00:00 sshd: postgres@pts/2
postgres 26264 26263  0 11:42 pts/2    00:00:00 -bash
postfix  26398  4792  0 11:56 ?        00:00:00 pickup -l -t fifo -u
root     26421  5099  0 11:59 ?        00:00:00 sshd: postgres [priv]
postgres 26425 26421  0 11:59 ?        00:00:00 sshd: postgres@pts/1
postgres 26426 26425  0 11:59 pts/1    00:00:00 -bash
postgres 26490     1  0 12:01 pts/1    00:00:00 /usr/local/pgsql/bin/postgres
postgres 26493 26490  0 12:01 ?        00:00:00 postgres: checkpointer process   
postgres 26494 26490  0 12:01 ?        00:00:00 postgres: writer process     
postgres 26495 26490  0 12:01 ?        00:00:00 postgres: wal writer process   
postgres 26496 26490  0 12:01 ?        00:00:00 postgres: autovacuum launcher process   
postgres 26497 26490  0 12:01 ?        00:00:00 postgres: stats collector process   
postgres 26499 26426  0 12:01 pts/1    00:00:00 ps -ef
postgres 26500 26426  0 12:01 pts/1    00:00:00 grep post
[postgres@myLinux002 ~]$ 




[postgres@myLinux002 ~]$ createdb db1
[postgres@myLinux002 ~]$ psql db1
psql (9.3.5)
Type "help" for help.


db1=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 db1       | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(5 rows)


db1=# \c db1
You are now connected to database "db1" as user "postgres".
db1=# 


b1-# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 db1       | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(5 rows)


db1-# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres-# 


b1=# create table a1(id int4,name char(5));
CREATE TABLE
db1=# \d
        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | a1   | table | postgres
(1 row)


db1=# \d a1
         Table "public.a1"
 Column |     Type     | Modifiers 
--------+--------------+-----------
 id     | integer      | 
 name   | character(5) | 






db1=# create index idx_a1_id on a1(id);
CREATE INDEX


db1=# \di
               List of relations
 Schema |   Name    | Type  |  Owner   | Table 
--------+-----------+-------+----------+-------
 public | idx_a1_id | index | postgres | a1
(1 row)


db1=# \di idx_a1_id
               List of relations
 Schema |   Name    | Type  |  Owner   | Table 
--------+-----------+-------+----------+-------
 public | idx_a1_id | index | postgres | a1
(1 row)


db1=# insert into a1 values (1,'abc');
INSERT 0 1
db1=# insert into a1 values (2,'test');
INSERT 0 1
db1=# select * from a1;
 id | name  
----+-------
  1 | abc  
  2 | test 
(2 rows)


db1=# 


[postgres@myLinux002 ~]$ pg_dump db1
--
-- PostgreSQL database dump
--


SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;


--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--


CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;




--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--


COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';




SET search_path = public, pg_catalog;


SET default_tablespace = '';


SET default_with_oids = false;


--
-- Name: a1; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--


CREATE TABLE a1 (
    id integer,
    name character(5)
);




ALTER TABLE public.a1 OWNER TO postgres;


--
-- Data for Name: a1; Type: TABLE DATA; Schema: public; Owner: postgres
--


COPY a1 (id, name) FROM stdin;
1       abc  
2       test 
\.




--
-- Name: idx_a1_id; Type: INDEX; Schema: public; Owner: postgres; Tablespace: 
--


CREATE INDEX idx_a1_id ON a1 USING btree (id);




--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--


REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;




--
-- PostgreSQL database dump complete
--


[postgres@myLinux002 ~]$ 




[postgres@myLinux002 ~]$ dropdb db1
[postgres@myLinux002 ~]$ psql
psql (9.3.5)
Type "help" for help.


postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)


postgres=# bye
postgres-# \q
[postgres@myLinux002 ~]$ psql db1
FATAL:  database "db1" does not exist
psql: FATAL:  database "db1" does not exist
[postgres@myLinux002 ~]$ createdb db1
[postgres@myLinux002 ~]$ psql db1
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
CREATE TABLE
ALTER TABLE
CREATE INDEX
REVOKE
REVOKE
GRANT
GRANT
[postgres@myLinux002 ~]$ psql db1
psql (9.3.5)
Type "help" for help.


db1=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 db1       | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(5 rows)


db1=# \di
               List of relations
 Schema |   Name    | Type  |  Owner   | Table 
--------+-----------+-------+----------+-------
 public | idx_a1_id | index | postgres | a1
(1 row)


db1=# \di
               List of relations
 Schema |   Name    | Type  |  Owner   | Table 
--------+-----------+-------+----------+-------
 public | idx_a1_id | index | postgres | a1
(1 row)


db1=# 
db1=# select * from a1;
 id | name  
----+-------
  1 | abc  
  2 | test 
(2 rows)


db1=# \d
        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | a1   | table | postgres
(1 row)


db1=# 




db1=# ALTER USER postgres WITH PASSWORD 'postgres';
ALTER ROLE
db1=# select * from pg_shadow ;
 usename  | usesysid | usecreatedb | usesuper | usecatupd | userepl |               passwd                | valuntil | useconfig 
----------+----------+-------------+----------+-----------+---------+-------------------------------------+----------+-----------
 postgres |       10 | t           | t        | t         | t       | md53175bce1d3201d16594cebf9d7eb3f9d |          | 
(1 row)


db1=# create database david;
CREATE DATABASE
db1=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 david     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 db1       | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(6 rows)


db1=# 


db1=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 david     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 db1       | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(6 rows)


db1=# \c david
You are now connected to database "david" as user "postgres".
david=# create table test (id integer, name text);
CREATE TABLE
david=# insert into test values (1,'david');
INSERT 0 1
david=# select * from test ;
 id | name  
----+-------
  1 | david
(1 row)


david=# 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8102208/viewspace-1337789/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-04-29

  • 博文量
    296
  • 访问量
    566578