PostgreSQL 2019(1)Install PostgreSQL 10.9 on Ubuntu

PostgreSQL2019(1)InstallPostgreSQL10.9onUbuntu

Currently,thelatestversionishttps://www.postgresql.org/ftp/source/v11.4/

>wgethttps://ftp.postgresql.org/pub/source/v11.4/postgresql-11.4.tar.gz

>tarzxvfpostgresql-11.4.tar.gz

ItseemsIneedversion10tosupportmysoftware.

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

>wgethttps://ftp.postgresql.org/pub/source/v10.9/postgresql-10.9.tar.gz

>tarzxvfpostgresql-10.9.tar.gz

>./configure--prefix=/home/carl/tool/postgresql-10.9

>make

>makeinstall

Installthetools

>cdcontrib/

>make

>makeinstall

AddtothePath

>sudoln-s/home/carl/tool/postgresql-10.9/opt/postgresql-10.9

>sudoln-s/opt/postgresql-10.9/opt/postgresql

exportPATH="/opt/postgresql/bin:$PATH"

Checkinstallationandversion

>postgres--version

postgres(PostgreSQL)10.9

Initthedatabase

>initdb-D/opt/postgresql/data/

Startthedatabaseservice

>pg_ctl-D/opt/postgresql/data/-llogfilestart

Listthedatabasewehave

>psql-l

Listofdatabases

Name|Owner|Encoding|Collate|Ctype|Accessprivileges

-----------+-------+----------+-------------+-------------+-------------------

postgres|carl|UTF8|en_US.UTF-8|en_US.UTF-8|

template0|carl|UTF8|en_US.UTF-8|en_US.UTF-8|=c/carl+

|||||carl=CTc/carl

template1|carl|UTF8|en_US.UTF-8|en_US.UTF-8|=c/carl+

|||||carl=CTc/carl

Createadatabase,ownercarl,databasenamedemo

>createdb-Ocarl-Eutf-8demo

Connecttothedatabase

>psql-Ucarl-ddemo-hlocalhost

Listalldatabaseafterthat

>\l

Listofdatabases

Name|Owner|Encoding|Collate|Ctype|Accessprivileges

-----------+-------+----------+-------------+-------------+-------------------

demo|carl|UTF8|en_US.UTF-8|en_US.UTF-8|

postgres|carl|UTF8|en_US.UTF-8|en_US.UTF-8|

template0|carl|UTF8|en_US.UTF-8|en_US.UTF-8|=c/carl+

|||||carl=CTc/carl

template1|carl|UTF8|en_US.UTF-8|en_US.UTF-8|=c/carl+

|||||carl=CTc/carl

Createtable

>demo=#createtableusertable(nameVARCHAR(20),signupdateDATE);

CREATETABLE

Insertdata

>insertintousertable(name,signupdate)values('sillycat','2019-07-23');

INSERT01

Selectdata

>select*fromusertable;

name|signupdate

----------+------------

sillycat|2019-07-23

Listallthetables

>\d

Listofrelations

Schema|Name|Type|Owner

--------+-----------+-------+-------

public|usertable|table|carl

Listtheconnection

>\conninfo

Youareconnectedtodatabase"demo"asuser"carl"onhost"localhost"atport"5432".

Password

>exportPGPASSWORD=test

>psql-Ucarl-ddemo-hubuntu-master-p5432

References:

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

相关推荐