CentOS to compile a tutorial on installing the PostgreSQL database

Source: Internet
Author: User
Tags postgresql psql readline centos mysql database

PostgreSQL is the first choice for open source relational databases, because the MySQL database is now being acquired by Oracle, so let's introduce a tutorial on compiling the PostgreSQL database in CentOS.

 


ReadLine is an open source Cross-platform library that provides interactive text editing capabilities. PostgreSQL needs ReadLine support.
Wget-c https://ftp.postgresql.org/pub/source/v9.3.5/postgresql-9.3.5.tar.gz
[Root@rootop postgresql-9.3.5]# yum install ReadLine readline-devel


[Root@rootop postgresql-9.3.5]#./configure--prefix=/usr/local/pgsql
[Root@rootop postgresql-9.3.5]# make
[Root@rootop postgresql-9.3.5]# make install

To add a System account:

[Root@rootop ~]# Useradd Postgres
[Root@rootop ~]# passwd Postgres

To create a data directory:

[Root@rootop ~]# Mkdir/usr/local/pgsql/data
[Root@rootop ~]# chown postgres:postgres/usr/local/pgsql/data/

Initialize database:

[Root@rootop ~]# su postgres #切换到postgres用户执行

[Postgres@rootop ~]$/usr/local/pgsql/bin/initdb-d/usr/local/pgsql/data/
According to the tips can be passed/usr/local/pgsql/bin/postgres-d/usr/local/pgsql/data/
or/usr/local/pgsql/bin/pg_ctl-d/usr/local/pgsql/data/-l logfile start service.

The following script startup method is recommended to listen for Port 5432 on TCP after startup.

[Postgres@rootop ~]$ lsof-i:5432
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
Postgres 5140 postgres 3u IPv4 2394876345 0t0 TCP localhost:postgres (LISTEN)

Copy management script (root operation):

[Root@rootop postgresql-9.3.5]# CP Contrib/start-scripts/linux/etc/init.d/postgresql
[Root@rootop postgresql-9.3.5]# chmod o+x/etc/init.d/postgresql

Edit the startup script and note the following sections for actual information:

#安装路径
Prefix=/usr/local/pgsql
#数据目录
Pgdata= "/usr/local/pgsql/data"
#启动用户
Pguser=postgres
#日志路径
pglog= "$PGDATA/serverlog"
Then it can be managed through the service PostgreSQL start|stop|restart|reload|status.

Boot start:

[root@ay131126202614070132z ~]# chkconfig PostgreSQL on

Related configuration file:
The/usr/local/pgsql/data/postgresql.conf allows you to configure the listener address, port, and number of connections.
Listen_addresses =
Port =
Max_connections =
You can configure the addresses that allow remote connections through/usr/local/pgsql/data/pg_hba.conf.
Host All 127.0.0.1/32 Trust

Log in to the database:


[root@ay131126202614070132z ~]#/usr/local/pgsql/bin/psql-h 127.0.0.1-d postgres-u postgres
Psql (9.3.5)
Type ' help ' for help.

Postgres=#\l #查看已有的数据库
List of databases
Name | Owner | Encoding | Collate | Ctype | Access Privileges
-----------+----------+----------+-------------+-------------+-----------------------
Postgres | Postgres | UTF8 | en_US. UTF-8 | en_US. UTF-8 |
Template0 | Postgres | UTF8 | en_US. UTF-8 | en_US. UTF-8 | =c/postgres +
| | | | | Postgres=ctc/postgres
template1 | Postgres | UTF8 | en_US. UTF-8 | en_US. UTF-8 | =c/postgres +
| | | | | Postgres=ctc/postgres
(3 rows)

Postgres=#\q #退出

Psql supported parameters can be obtained by/usr/local/pgsql/bin/psql--help
Installation complete.

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.