Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL Connect Database

  • A database is a named collection of SQL objects ("database objects LIKE tables, functions,etc") that belongs to only one database. 
  • But there are a few system catalogs eg - pg_database, which belong to a whole cluster and are accessible from each database within the cluster.
Accurately, a database is a collection of schemas
Schemas contain the tables, functions, etc...
hierarchy is Server, database, schema, table
  • a client must specify its connection request and the name of the database it wants to connect to. It is not possible to access more than one database per connection.
  • But an application is not restricted in the number of connections it opens to the same or other databases. 
  • Databases arc physically separated and access control is managed at the connection level. If one PostgreSQL server instance is to house projects or users that should be separate and for the most part unaware of each other,
  • it is therefore recommendable to put them into separate databases.
  • If the projects or users are interraelated and hould be able to use each others resources they should be put in the same database, but possibly into separate schemas.
  • Schemas is logical structure for who can access what is managed by the privilege system.
Check Whether Our Postgres Server is run or not:
[postgres@r1 bin]$ ps -ef|grep post
root 5073 4719 0 14:24 pts/1 00:00:00 su - postgres
postgres 5074 5073 0 14:24 pts/1 00:00:00 -bash
root 5149 4996 0 14:27 pts/2 00:00:00 su - postgres
postgres 5150 5149 0 14:27 pts/2 00:00:00 -bash
postgres 5188 1 0 14:28 pts/2 00:00:00 /opt/PostgreSQL/9.3/bin/postgres -D /opt/PostgreSQL/9.3/data
postgres 5189 5188 0 14:28 ? 00:00:00 postgres: logger process
postgres 5191 5188 0 14:28 ? 00:00:00 postgres: checkpointer process
postgres 5192 5188 0 14:28 ? 00:00:00 postgres: writer process
postgres 5193 5188 0 14:28 ? 00:00:00 postgres: wal writer process
postgres 5194 5188 0 14:28 ? 00:00:00 postgres: autovacuum launcher process
postgres 5195 5188 0 14:28 ? 00:00:00 postgres: stats collector process
postgres 5215 5074 0 14:29 pts/1 00:00:00 ps -ef
postgres 5216 5074 0 14:29 pts/1 00:00:00 grep post

Connect The Postgres Server:
[root@r1 data]# su - postgres  
[postgres@r1 bin]$ ./psql -p 5432 -U postgres -d postgres
Password for user postgres:
psql.bin (9.3.14)
Type "help" for help.

No entry for terminal type "xterm";
using dumb terminal settings.
postgres=#
Conform to connect the right port:
postgres=# select inet_server_port();
inet_server_port
------------------
5432
(1 row)
Conform to connected database:
postgres=# select current_database();
current_database
------------------
postgres
(1 row)
Conform to connect the right user:
postgres=# select current_user;
current_user
--------------
postgres
(1 row)
Conform to connected ip address:
postgres=# select inet_server_addr();
inet_server_addr
------------------
192.168.1.112
(1 row)
Check what Postgresql version you are using:

postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.14 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52), 32-bit
(1 row)

Comments

Popular posts from this blog

PostgreSQL pgBadger

How To Schedule PostgreSQL Jobs using pgAgent on Linux plateform

PostgreSQL Pgbadger Installation On Linux

How to configure Replication Manager (repmgr) ?

Script to kill ALL IDLE Connection In postgreSQL