在Debian10系统上,安装和使用PostgreSQL数据库 2021-06-15


官网 https://www.postgresql.org/
安装 https://www.postgresql.org/download/
Debian系统的安装 https://www.postgresql.org/download/linux/debian/
英文教程,多版本 https://www.postgresql.org/docs/
中文教程才到12的版本 http://www.postgres.cn/docs/12/

# Update and install the basic 
root@debian-server:~# apt update
root@debian-server:~# apt install lsb-release
root@debian-server:~# apt install gnupg2
root@debian-server:~# apt install wget
root@debian-server:~# apt install curl

# Create the file repository configuration
root@debian-server:~# sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key
root@debian-server:~# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

# Update the package lists
root@debian-server:~# apt-get update

# Install the latest version of PostgreSQL
root@debian-server:~# apt-get -y install postgresql


root@pve-debian-server-02:~# su - postgres
postgres@pve-debian-server-02:~$ psql -c "SELECT version();"
                                                     version                                                      
------------------------------------------------------------------------------------------------------------------
 PostgreSQL 14.0 (Debian 14.0-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
(1 row)
// 2021-11-04 安装到的14.0的最新版本的,真棒!

postgres@pve-debian-server-02:~$ pg_isready 
/var/run/postgresql:5432 - accepting connections
postgres@pve-debian-server-02:~$ 
postgres@pve-debian-server-02:~$ psql --version
psql (PostgreSQL) 13.3 (Debian 13.3-1.pgdg100+1)
postgres@pve-debian-server-02:~$ 
postgres@pve-debian-server-02:~$ createdb apgdatabase
postgres@pve-debian-server-02:~$ 
postgres@pve-debian-server-02:~$ createuser apguser
postgres@pve-debian-server-02:~$ 
postgres@pve-debian-server-02:~$ psql
psql (13.3 (Debian 13.3-1.pgdg100+1))
Type "help" for help.

postgres=# alter user apguser with password 'YourPasswd';
ALTER ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE apgdatabase TO apguser;
GRANT
postgres=# \q
postgres@pve-debian-server-02:~$ 
postgres@pve-debian-server-02:~$ psql -d apgdatabase
psql (13.3 (Debian 13.3-1.pgdg100+1))
Type "help" for help.

apgdatabase=# SELECT current_date;
 current_date 
--------------
 2021-06-14
(1 row)

apgdatabase=# 
apgdatabase=# 
apgdatabase=# \q
postgres@pve-debian-server-02:~$ 


2021-11-1 增加,使用root重置一次postgres账户的密码,到一个复杂密码
root@server# passwd postgres
Donate
云乞讨

在Debian10系统上,安装和使用PostgreSQL数据库 2021-06-15》有1个想法

  1. Pingback引用通告: 项目编号~/project/PAF5 之 PostgreSQL 13.3数据库设计 核心数据表设计 2021-6-22 | Dasmz

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注