Latest News: Linux shell script to change you ssh port

Install PostgreSQL and phpPgAdmin on Debian 7 ‘Wheezy’

Tutorial willing 295View(s) 0Comment

PostgreSQL is a powerful, open-source object-relational database system. It runs on all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS, Solaris, Tru64), and Windows OS. In this handy tutorial, let us see how to install PostgreSQL on Debian 7 ‘Wheezy’.

Install PostgreSQL

Switch to root user using the command:

Install it with following command:

Access PostgreSQL

The default database name and database user are called postgres. Switch to postgres user to perform postgresql related operations:

To login to postgresql, enter the command:

To exit from posgresql, type \q.

Set “postgres” password

Login to postgresql and set postgres password with following command:

To install PostgreSQL Adminpack, enter the command in postgresql prompt:

Create New User and Database

First create a regular system user from your Terminal. For example, here I create a new user called “kumar” with password “debian” and database called “mydb”.

First create a user called “kumar” as regular system user. To do this, enter the following command from your terminal:

Switch to postgres user with command:

Enter the following commands to create user “kumar”:

Login to postresql command prompt:

Enter the following command to set password for user “kumar”:

Exit form postgresql prompt and switch to the newly created user “kumar”:

Enter the command to create database called mydb:

Now the user “kumar” and database “mydb” are created.

Connect to newly created database “mydb” using the following command:

Delete Users and Databases

To delete the database, switch to postgres user:

Enter command:

To delete a user, enter the following command:

Configure PostgreSQL-MD5 Authentication

By default, Posgresql uses ident authentication, so that the local system users can be granted access to databases own by them. If you want to set MD5 authentication to require users to enter passwords.

Open up the /etc/postgresql/9.1/main/pg_hba.conf file:

Find the following line:

Change to:

Restart postgresql to apply the changes:

Now you will be asked password every time while connecting to databases.

Configure PostgreSQL-Configure TCP/IP

By default, TCP/IP connection is disabled, so that the users from another computers can’t access postgresql. To allow to connect users from another computers, open the file /etc/postgresql/9.1/main/postgresql.conf:

Find the line:

Uncomment and set the IP address of your postgresql server as shown below:

And find the line:

Uncomment it by removing the # symbol to look like below:

Restart postgresql service to save changes:

Manage PostgreSQL with phpPgAdmin

phpPgAdmin is a web-based administration utility written in PHP for managing PosgreSQL.

To install phpPgAdmin, enter the following command:

By default, you can access phppgadmin using http://localhost/phppgadmin from your local system only. To access remotely, do the following,

Open up the file /etc/apache2/conf.d/phppgadmin:

Find the line:

Uncomment it by removing the # symbol and make it look like below:

Restart Apache service:

Now open your browser and navigate to http://ip-address/phppgadmin. You will be pleased when you see the following screen.

phpPgAdmin - Mozilla Firefox_001Login with users that you’ve created earlier. You may get an error:

phpPgAdmin - Mozilla Firefox_002To fix this error, open the file /usr/share/phppgadmin/conf/config.inc.php:

Find the following line:

And remove localhost to make it look like below:

And find the line:

Change the value to false:

Save and close the file. Restart postgresql service and Apache service:

Now you will be able to login to phpPgAdmin.

phpPgAdmin - Mozilla Firefox_003That’s it. Now you’ll able to perform create, delete and alter databases graphically.

 

Souce:https://www.unixmen.com/install-postgresql-and-phppgadmin-on-debian-7-wheezy/

Please give credit to the original author when you use it elsewhere: VPS List Agent » Install PostgreSQL and phpPgAdmin on Debian 7 ‘Wheezy’

Login to post a comment!