Skip to main content

Posts

Showing posts with the label postgre database

How to manage postgres through command line in Ubuntu?

Step 1: First install postgres in Ubuntu system using following commands. $ sudo apt-get update $ sudo apt-get install postgresql postgresql-contrib libpq-dev To check psql (postgres) version. $  psql –version Step 2:  Now to create root user and password for psql. $  sudo -u postgres createuser -s root $  sudo -i -u  postgres Now, you are in postgres environment. postgres@admin:~$ Now, use the following command to enter and manage psql. postgres@admin:~$  psql Now, set the password for psql username “ root ”. postgres=# \password root enter password confirm Now, you can exit from psql using following command postgres=# \q Step 3:  Create new user and database in psql $ sudo su postgres $ psql -c "create user mack with password 'mack'" $ psql -c "create database mackdb owner mack" $ sudo -i -u postgres postgres@admin:~$  psql Step 4:  Give all privileges over database to a particular user. postgres=# grant all...