Open the terminal and type following command to install postgresql
sudo apt-get install postgresqlPostgreSQL Configuration:
After successful installation of postgresql, you can configure postgresql using configuration file /etc/postgresql/9.1/main/postgresql.conf (9.1 is the version of postgresql installed under Ubuntu)
By default, connections via TCP/IP is disabled due to which users will not be able to access PostgreSQL server from another computers. To enable TCP/IP Connection edit the file /etc/postgresql/9.1/main/postgresql.conf and make the following changes.
Change #listen_addresses = localhost to ....
listen_addresses =192.168.1.1and #password_encryption = on to ...
password_encryption = on
NOTE: All the commands below are executed as the postgres privileged user.
Create the user
Go to terminal and type command createuser and answer few quetion to create postgreSQL user
sudo -u postgres createuserCreate the PostgreSQL Database:
Enter name of role to add: linuxpoison
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE
Use the command createdb command to create the database :
sudo -u postgres createdb linuxdbGrand access to the user for the database:
CREATE DATABASE
And last, using the psql command, set a password for the user and grant accesses :
sudo -u postgres psql
postgres=# alter user linuxpoison with encrypted password 'password';
ALTER ROLE
postgres=# grant all privileges on database linuxdb to linuxpoison;
GRANT
sudo apt-get install postgresql-clientAfter successful installation of the postgresql client on the client machine, you then connect to the server with the following command
psql -h <postgresql_server_name> <database_name> <username>After you inserted the password you access PostgreSQL with line commands.
Use the following command (from terminal) to control the PostgreSQL server
Start the service : /etc/init.d/postgresql start
Stop the service : /etc/init.d/postgresql stop
Know the status : /etc/init.d/postgresql status
Restart the service : /etc/init.d/postgresql restart
No comments:
Post a Comment