PostgreSQL Source Installation

Source: Internet
Author: User
Tags mkdir psql


PostgreSQL Source Installation


Download PostgreSQL installation package


wget https://ftp.postgresql.org/pub/source/v9.5.7/postgresql-9.5.7.tar.gz


Download website

https://www.postgresql.org/ftp/source/


Install dependent packages

Yum-y Install Readline-devel Zlib-devel


Unpacking-configuration-compile-install

TAR-XF postgresql-9.5.7.tar.gz

CD postgresql-9.5.7

./configure--prefix=/usr/local/postgresql

Make && make install


Default Superuser (Root) cannot start PostgreSQL

Useradd Postgres

Mkdir-p/data/postgresql/data

Mkdir-p/data/postgresql/data/log

Chown-r postgres:postgres/usr/local/postgresql/

Chown-r postgres:postgres/data/postgresql/data/


For convenience, set the POSTGRES environment variable

Su-postgres//Switch to Postgres user

[[email protected] ~]$ vim. Bash_profile

#. bash_profile# Get the aliases and Functionsif [-f ~/.BASHRC]; Then. ~/.bashrcfi# User specific environment and startup Programspghome=/usr/local/postgresql #psql安装目录export pghomepgdata=/ Data/postgresql/data #数据库目录export pgdatapath= $PATH: $HOME/bin: $HOME/.local/bin: $PGHOME/binexport PATH


source./.bash_profile make it effective immediately


[email protected] ~]$ which psql

/usr/local/postgresql/bin/psql

[Email protected] ~]$ psql-v

Psql (PostgreSQL) 9.5.7


Initializing the database

Initdb

Success. You can now start the database server using:pg_ctl-d/data/postgresql/data-l logfile start


Start Psql

pg_ctl-d/data/postgresql/data-l/data/postgresql/data/log/postgres.log Start


Set the PostgreSQL password,

[Email protected] data]$ Psql

Psql (9.5.7)

Type ' help ' for help.

postgres=# \password

Enter New Password://password

Enter it again://Confirm Password


Modify PostgreSQL Password

[Email protected] data]$ Psql

Password:

Psql (9.5.7)

Type ' help ' for help.

postgres=# alter user postgres with password ' 123456 ';

ALTER ROLE

postgres=# \q


The default Psql local login does not require a password, even if we set a password, we do not need a password to log in. Should be the configuration file pg_hba.conf in the local set as the trust, in order to secure our changes to password, is to use the password to login, (when we forget the password time, you can also use this method, first set as the trust, change the password, Then set to password. )


[[Email protected] ~] $CD/data/postgresql/data

[Email protected] data]$ vim pg_hba.conf

Local all password #默认trust, log on locally without password, set to password with password. Host all 0.0.0.0/0 password #ip地址修改为0.0.0.0/0,


Modify Psql Default port

[Email protected] data]$ vim postgresql.conf

listen_addresses = ' * ' #127.0.0.1 only allow local access, set to * allow the entire network. Port = 5432 #监听端口


Need to restart Psql to take effect after modification


pg_ctl-d/data/postgresql/data-l/data/postgresql/data/log/postgres.log Restart









This article is from "Linux operations-Small Ink" blog, please be sure to keep this source http://xmomo.blog.51cto.com/5994484/1973684

PostgreSQL Source Installation

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.