PostgreSQL 10 Linux installation

Environmental preparation

Server: Linux SUSE 11
Version: PostgreSQL 10.3

1. Download the latest version of postgresql-10.3.tar.gz
, there are net rules:

wget https://ftp.postgresql.org/pub/source/v10.3/postgresql-10.3.tar.gz

No network: windows download and upload to linux specified folder

2. Create the postgres user and group to extract the file

groupadd postgres
useradd -g postgres postgres
chown postgres:postgres /home/super/soft/pgdatabase -R
cd /home/super/soft
tar -zxvf postgresql-10.3.tar.gz 
    -z :有gzip属性的
    -x:解压
    -v:显示所有过程
    -f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。

3. Compile

cd home/super/soft/postgresql-10.3 
./configure --prefix=/home/super/soft/postgreSql10 --without-readline -E zh_CN.GBK

 ./configure 用于linux安装文件的环境配置检测
 --prefix 用于指定文件目录 
 --without-readline 表示忽略该依赖readline 文件的检查

Question 1:
write picture description here

4. Download the software zlib-1.2.11.tar.gz and decompress it

 tar zlib-1.2.11
 cd zlib-1.2.11/
 ./configure  
 make && make install

Go back to the decompressed directory of pgsql, re-execute ./configure detection, compile

./configure --prefix=/home/super/soft/postgreSql10 --without-readline
make && make install

5. Set environment variables, otherwise commands such as initdb cannot be executed

    Ø cd /etc 
    Ø vi profile
    Ø export    PGHOME=/home/super/soft/postgresql-10.3  
    Ø export    PGDATA=~/home/super/soft/pgdatabase 
    Ø export    PATH=$PATH:$HOME/bin:/home/super/soft/postgreSql10/bin  
    Ø export PG_PATH=/home/super/soft/postgreSql10/bin
    Ø export PATH=$PG_PATH:$PATH

    加入后通过按 esc 按:wq保存并退出,通过source /etc/profile 

6. Initialize the database, do not support Chinese, need to set utf8

initdb -D /home/super/soft/pgdatabase  -E UTF-8 --locale=zh_CN.UTF-8

7. Modify the port and monitoring of the default configuration file.
Enter the pgsql database installation directory and open the client authentication configuration pg_hba.conf file to add the address that needs to be connected. The
method needs to be set to trust, then the IP can be connected remotely

8. Start PostgreSQL

pg_ctl -D /home/super/soft/pgdatabase/ start

closure

pg_ctl -D /home/super/soft/pgdatabase/ stop

reboot

pg_ctl -D /home/super/soft/pgdatabase/ reload

9. View the status of the current database

ps -ef|grep postgres

10. Connect to the database test

psql -p 5432 -U postgres -d postgres
create database test;
\l

11. Create a character

CREATE ROLE postgres login replication encrypted password '123456'

12. Modify user password

First, set the IP address to trust, and then log in to postgresql to execute sql

Ø ALTER USER postgres WITH PASSWORD 'postgres';

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325626625&siteId=291194637