$ sudo apt-get install postgresql postgresql-client postgresql-contribThis installs both server and client postgres on your machine, but the server is more relevant in this article. Secondly, we need to reset the ‘postgres’ user password, which is the admin account for the postgres server: Login as the root:
$ suThen login to postgres without needing a password
$ su - postgresNow login to the postgres template database:
$ psql template1 template1=# ALTER USER postgres WITH PASSWORD 'your_new_password';Type in
template1=# \\qto quit. The password for the postgres account in the database has been updated, now we need to do the same for unix user ‘postgres’: Clear the password for postgres first,
$ sudo passwd -d postgresThen update the password
$ passwdNow enter the same password that you used previously. You should now be able to login to postgres using the ‘postgres’ account:
$ psql -U postgresA welcome message should display:
Welcome to psql 8.2.7, the PostgreSQL interactive terminal. Type: \\copyright for distribution terms \\h for help with SQL commands \\? for help with psql commands \\g or terminate with semicolon to execute query \\q to quitThe database should be empty, and you are ready to start creating new databases and tables.