Installation Environment:
Ubuntu 14
PostgreSQL 9.0
1. Installing PostgreSQL
Enter the following command
sudo apt-get install PostgreSQL
You will be prompted to install the required disk space, enter "Y" and the Setup program will complete automatically. After installation, the system creates a database Superuser "Postgres" with a blank password. This user is both a non-logged operating system user and a database user.
2. Modify the password for Linux user Postgres
Enter the following command
sudo passwd postgres
3. Modify the password of the database super user Postgres
1) switch to Linux under Postgres user
sudo su postgres
2) Log in to the Postgres database
Psql Postgres
This way you will see the Postgres prompt message as follows:
Psql (8.4.4)
Type ' help ' for help.
and the command line prompt symbol for Postgres appears:
postgres=#
3) Enter the following command
ALTER USER postgres with PASSWORD ' PASSWORD '
type "Exit" to return to the Linux command line.
4. Add your own defined users and databases
1) Add New user
CREATEUSER-DRSP Fedoraadmin
follow the prompts to enter the user's password.
2) Create a database that belongs to the custom user Fedoraadmin
Createdb-o Fedoraadmin MyDB
The Postgressql database can be connected in Java through the following configuration, as set up above
User:fedoraadmin
Password:your Password
Url:jdbc:postgresql://localhost:5432/mydb
5. Installing pgAdmin3
1) Type the following command to install PgAdmin3
sudo apt-get install pgadmin3
2) Type the following command to run PgAdmin3
Pgadmin3
you will see that the main interface of PgAdmin3 is as follows:
Add the appropriate parameters to create a connection to PostgreSQL:
6. Setting up access to postgres on other machines
Modify/etc/postgresql/8.4/main/pg_hba.conf:
Host all 0.0.0.0/0 MD5 #0.0.0.0 is the address segment, and 0 is the number of bits
For example: 192.168.0.0/16 represents 192.168.0.1-192.168.255.254
Modify/etc/postgresql/8.4/main/postgresql.conf
listen_address = ' * '
Restart database
sudo/etc/init.d/postgresql-8.4 restart