Posts

Showing posts from November, 2017

Connecting to PostgresSQL database

After logging into postgres user, from cmdline type psql. bash-4.1$ psql could not change directory to "/var/lib/mysql/TESTDB" psql (8.4.18) Type "help" for help. Some basic cmds: postgres=# show databases;   -- This list databases postgres=# List databases      -- This list databases -- Listing database in postgres ##     \l will give you basic information of databases in instance postgres-# \l                                   List of databases    Name    |  Owner   | Encoding |  Collation  |    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                                    

Starting and shuting down Postgres server

Here are simple steps on how to start or stop PostgreSQL server. ---------------------------------------------------- -- SHUTDOWN POSTGRES ---------------------------------------------------- /etc/rc.d/init.d/postgresql stop [root@OEL1 local]# su postgres bash-4.1$ pg_ctl stop pg_ctl: no database directory specified and environment variable PGDATA unset Try "pg_ctl --help" for more information. bash-4.1$ pwd /usr/local bash-4.1$ cd bash-4.1$ . .bash_profile [postgres@OEL1:~]$ pg_ctl stop waiting for server to shut down.... done server stopped [postgres@OEL1:~]$ ps -ef|grep postgres root      2772  2737  0 10:32 pts/1    00:00:00 su postgres postgres  2773  2772  0 10:32 pts/1    00:00:00 bash postgres  2810  2773  0 10:33 pts/1    00:00:00 ps -ef postgres  2811  2773  0 10:33 pts/1    00:00:00 grep postgres ---------------------------------------------------- -- STARTUP POSTGRES ---------------------------------------------------- /etc/rc.d/init.