PostgreSQL9.2 Installation and Configuration guide

Source: Internet
Author: User
Tags md5 postgresql psql

This article only describes the installation and configuration process of PostgreSQL9.2 on CentOS.

1. Implement the Yum command to install PostgreSQL

Yum Install Postgresql-server

2. Initialize PostgreSQL database

Service PostgreSQL Initdbchkconfig PostgreSQL on

3. Configure PostgreSQL to support remote access

1. Modify/data/postgresql.conf Listen to this network, will listen_addresses the previous # removed, and will listen_addresses= ' localhost ' modified to Listen_ Addresses= ' * ' to change ports, to modify port= 5432 2. Modify the/data/pg_hba.conf format is "Type Database User Address Method"  The best way to write MD5, if you want to include how many values by method, pg_hba.conf inside has a detailed description of the style: host all 0.0.0.0/0 MD545. With PSQ L Log In

4. Modify the PostgreSQL port

1. Modify/data/postgresql.conf Modify Port, remove the # in front of port andchange port = 5432 to port=54332. Modify/etc/init.d/  PostgreSQLModifies port = 5432 to port=54333. Restart Services, service postgrep Restart4, view ports, Netstat-tuln

5, Database Common commands

1. Log in to the PostgreSQL console using the Psql command. Psql2. Use the \password command to set a password for the Postgres user. \password postgres3' password '; 4. Create the user database, here is Exampledb, and specify the owner as Dbuser. CREATE DATABASE exampledb OWNER dbuser; 5. Assign all permissions to the Exampledb database to Dbuser, otherwise dbuser can only log in to the console without any database operation permissions. GRANT all privileges on the DATABASE exampledb to Dbuser; 6. Use the \q command to exit the console (you can also press CTRL +D directly). \q
7. Log in to the database
After adding a new user and a new database, the database will be logged in the name of the new user, using the psql command.
Psql-u dbuser-d exampledb-h 127.0.0.1-p 5432

The parameters of the above command have the following meanings:-u Specify the user,-D specify the database,-h specifies the server,-p specifies the port.

After entering the above command, you will be prompted to enter the password for the Dbuser user. Enter it correctly and you can log in to the console.

The Psql command has a shorthand form. If the current Linux system user is also a PostgreSQL user, you can omit the user name (the part of the-u parameter). For example, my Linux system user name is RUANYF, and the PostgreSQL database has the same name as the user, then I log on to the Linux system as RUANYF, you can directly use the following command to log into the database, and do not require a password.

6, Database common operation

# Create a new table USER_TBL (name VARCHAR (), signup_date date), insert data into USER_TBL (name, Signup_dat e) VALUES (' Zhang San ', ' 2013-12-22 '*= ' John Doe ' WHERE name = ' Zhang San '= ' John Doe ' ; # add field ALTER TABLE user_t BL ADD Email VARCHAR (+) # UPDATE structure ALTER TABLE USER_TBL ALTER COLUMN signup_date SET not null;# rename field ALTER TABLE use  R_TBL RENAME column signup_date to signup;# delete field ALTER TABLE USER_TBL DROP column email;# table renamed ALTER TABLE USER_TBL RENAME To backup_tbl;# Delete tables drop table IF EXISTS backup_tbl;

Article Reference Source:

https://www.postgresql.org/download/linux/redhat/

Http://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html

Http://blog.sina.com.cn/s/blog_90474a92010128yl.html

Http://www.cnblogs.com/jevonsea/archive/2013/01/24/2874184.html

PostgreSQL9.2 Installation and Configuration guide

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.