I am sure that you will hate me when you read this post. Because It is very easy to install PostgreSQL 9.4 in Ubuntu 14.04. However, It works for me. And I hope you too.
Create file /etc/apt/sources.list.d/pgdg.list, with content:
1 |
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main |
Import key and update repositories:
1 2 3 |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ sudo apt-key add - sudo apt-get update |
And install PostgreSQL 9.4:
1 |
sudo apt-get install postgresql-9.4 |
Finally, test it:
1 |
sudo -u postgres psql |
The result should be:
1 2 3 4 |
psql (9.4.4) Type "help" for help. postgres=# |
Tips
And try to create a account with database:
1 2 3 4 5 6 |
CREATE USER thanhson1085 WITH PASSWORD 'jRVAp6tE'; CREATE DATABASE userdb; GRANT ALL PRIVILEGES ON DATABASE userdb TO thanhson1085; \connect userdb GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO thanhson1085; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO thanhson1085; |
To support remote access with account you just created. You should change file /etc/postgresql/9.4/main/pg_hba.conf.
The below is some commands we usually use in PSQL
Export data to sql file:
1 |
sudo -u postgres pg_dump -f userdb.sql -d userdb |
Import from SQL file
1 |
sudo -u postgres psql -f userdb.sql userdb |
Reset serial number:
1 |
ALTER SEQUENCE product_id_seq RESTART WITH 1453; |