Description
I am using the root user login at the terminal, if the non-root user, that in the command before the need to add "sudo", you understand ...
First step: install PostgreSQL under Ubuntu
1. Installing with Apt-get install
[Email protected]:~#apt-get install-y postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1 postgresql-server-dev-9.1
[code Description]
Install the server and command-line client psql. Wait a while, the system will automatically download the installation files from the Internet and complete the installation
Step Two: Modify the default user postgres password for the PostgreSQL database (note that it is not a Linux system account)
2.PostgreSQL Login (login with psql client)
[Email protected]:~#sudo-u postgres psql
//Where Sudo-u postgres is used to login with Postgres user
//postgresql data By default creates a Postgres database user as the administrator of the database, the password is random, so here
Set to' Postgres '
3. Modify the PostgreSQL login password:
postgres=#ALTER USER postgres with PASSWORD ' postgres ';
//postgres= #为PostgreSQL下的命令提示符
4. Exiting the PostgreSQL psql client
postgres=#\q
[code Description]
the characters before ' # ' and ' # ' are the system prompt, ' postgres=# ' is the prompt for the Psql client, and the red character is the input command (the rest of this article is also true);
[function Description]
PostgreSQL data By default will create a Postgres database user as the administrator of the database, the password is random, I need to change to the specified password, which is set to ' Postgres '
Step Three: Modify the Postgres user's password for the Linux system (the password is the same as the password for the database user postgres)
sudo passwd-d postgres
passwd:password expiry information changed.
//passwd-d Is the meaning of emptying the specified user password
postgresql data creates a Linux user Postgres by default, and changes the password to ' Postgres ' via the code above (depending on
password in the second step , as long as they are the same).
Now, we can use the Postgres account on the database server to operate the database through Psql or pgadmin and so on clients.
[Email protected]:~#sudo-u postgres passwd
Enter a new UNIX password:
Re-enter the new UNIX password:
passwd: Password has been successfully updated
Fourth Step: Modify the Postgressql database configuration for remote access
[Email protected]:~#vi/etc/postgresql/9.1/main/postgresql.conf
1. Listen to any address interview, modify the connection permissions
#listen_addresses = ' localhost ' instead listen_addresses = ' * '
2. Enable password verification
#password_encryption = oninsteadpassword_encryption = on
3. Accessible User IP segment
[Email protected]:~#vi/etc/postgresql/9.1/main/pg_hba.conf , and add the following to the end of the document
# to allow your client visiting PostgreSQL server
Host all 0.0.0.0 0.0.0.0 MD5
4. RestartPostgreSQL Database
[Email protected]:~#/etc/init.d/postgresql Restart
Fifth Step:manage PostgreSQL users and databases
1. Log in to Postgre SQL database
[Email protected]:~#psql-u postgres-h 127.0.0.1
2. Create a new user Zhaofeng, but do not give permission to build the database
postgres=#Create user "Zhaofeng" with password ' 123456 ' nocreatedb;
//NoteUser names are double-quoted to be case-sensitive, and passwords are not
3. Create a database and specify the owner
postgres=#CREATE DATABASE "TestDB" with owner= "Zhaofeng";
4. Administrative commands on the external command line
[Email protected]:~#- u postgres createuser -d-p test1
//- d The user does not have the right to create a database,-p prompts for a password, and selects the management type y/n
[Email protected]:~#- u postgres createdb-o test1 db1
//-O set owner to Test1
Sixth step:installation PostgreSQL Database pgAdmin3 Client Management program
[Email protected]:~#apt-get install-y pgadmin3
11.10 The installation and configuration of the Postgresql-9.1 "title=" [Reprint]ubuntu11.10 The installation and configuration of the Postgresql-9.1 "height=" 255 "width=" 404 ">
11.10 The installation and configuration of the Postgresql-9.1 "title=" [Reprint]ubuntu11.10 The installation and configuration of the Postgresql-9.1 "height=" 545 "width=" 690 ">
PS: If you want to start pgadmin in the Ubuntu GUI, just press the keyboard's Windows key, enter Pgadmin in the search, you can find it, click on it to start. If you want to make it easy to use later, you can drag it to the launcher to lock it up.
Ubuntu 12.04 under PostgreSQL-9.1 installation and configuration (online installation)