Ubuntu 12.04 PostgreSQL-9.1 online installation and configuration details

Source: Internet
Author: User
Tags psql postgres createdb postgres database

Ubuntu 12.04 PostgreSQL-9.1 online installation and configuration details

Note:

I log on to the terminal using a root user. If it is not a root user, add "sudo" before the command, you know...

Step 1: Install Postgresql in Ubuntu

1. Use apt-get install to install
Root @ server2-virtual-machine :~ # Apt-get install-y postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1 postgresql-server-dev-9.1 [code description] install server and command line Client psql. Wait for a while, the system will automatically download the installation file from the Internet and complete the installation

Step 2: Modify the default PostgreSQL database user's postgres password (note that it is not a linux Account) 2. log on to PostgreSQL (use the psql client to log on)
Root @ server2-virtual-machine :~ # Sudo-u postgres psql
// Sudo-u postgres indicates using postgres user logon.
// PostgreSQL data creates an postgres database user by default as the database administrator. The password is random, so here
// Set it to 'second s'
3. Modify the PostgreSQL logon password:
S = # alter user Login s with password 'login s ';
// Postgres = # the command prompt in PostgreSQL
4. log out of the PostgreSQL psql Client
Postgres = # \ q
[Code description]
The characters before '#' and '#' are the system prompt, 'Seconds S = # 'is the prompt of the psql client, and the red character is the input command (this is also true for other parts of this article );
[Function description]
By default, PostgreSQL data will create a postgres database user as the database administrator. The password is random and we need to change it to the specified password. Here we set it to's S' Step 3: modify the password of the postgres user in linux (the password is the same as that of the Database User postgres)
1. Delete the PostgreSQL User Password
Root @ server2-virtual-machine :~ # Sudo passwd-d postgres
Passwd: password expiry information changed.
// Passwd-d Indicates clearing the specified user password.
2. Set the PostgreSQL User Password
PostgreSQL data creates a linux user named S by default, and uses the above Code to change the password to 'postgres' (depending on
The password in step 2, as long as it is the same ). Now, we can use the postgres account on the database server to operate the database through clients such as psql or pgAdmin.
Root @ server2-virtual-machine :~ # Sudo-u postgres passwd
Enter a new UNIX Password:
Re-enter the new UNIX Password:
Passwd: the password is successfully updated.

Step 4: Modify the PostgreSQL database configuration for remote access
Root @ server2-virtual-machine :~ # Vi/etc/postgresql/9.1/main/postgresql. conf
1. Listen to access from any address and modify the connection permission
# Change listen_addresses = 'localhost' to listen_addresses = '*'
2. Enable password verification
# Change password_encryption = on to password_encryption = on
3. accessible user ip segments
Root @ server2-virtual-machine :~ # Vi/etc/postgresql/9.1/main/pg_hba.conf, and add the following content at the end of the document
# To allow your client visiting postgresql server
Host all 0.0.0.0 0.0.0.0 md5
4. Restart the PostgreSQL database
Root @ server2-virtual-machine :~ #/Etc/init. d/postgresql restart


Step 5: Manage PostgreSQL users and databases
1. log on to the postgre SQL database
Root @ server2-virtual-machine :~ # Psql-U postgres-h 127.0.0.1
2. Create a new user zhaofeng, but do not grant the database creation permission
Postgres = # create user "zhaofeng" with password '000000' nocreatedb;
// Note that the user name must be enclosed in double quotation marks to be case sensitive and the password is not used
3. Create a database and specify the owner
S = # create database "testdb" with owner = "zhaofeng ";
4. Manage commands in the external command line
Root @ server2-virtual-machine :~ #-U postgres createuser-D-P test1
//-D this user does not have the right to create a database.-P prompts you to enter the password and select the management type y/n.
Root @ server2-virtual-machine :~ #-U postgres createdb-O test1 db1
//-O: Set the owner to test1.

Step 6: Install the postgresql database pgAdmin3 Client Management Program
Root @ server2-virtual-machine :~ # Apt-get install-y pgadmin3
PS: If you want to start pgadmin In the Ubuntu graphic interface, you only need to press the windows key on the keyboard and enter pgadmin in the search box, you can find it and click it to start it. To facilitate future use, you can drag it to the initiator to lock it.

------------------------------------ Lili split line ------------------------------------

Compile and install the PostgreSQL 6.5 database on CentOS 9.3

Install PostgreSQL 6.3 on yum in CentOS 9.3

PostgreSQL cache details

Compiling PostgreSQL on Windows

Configuration and installation of LAPP (Linux + Apache + PostgreSQL + PHP) Environment in Ubuntu

Install and configure phppgAdmin on Ubuntu

Install PostgreSQL9.3 on CentOS

Configure a Streaming Replication cluster in PostgreSQL

------------------------------------ Lili split line ------------------------------------

PostgreSQL details: click here
PostgreSQL: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.