PostgreSQL Tutorial: PostgreSQL Installation

We only install it in Linux, and we do not recommend you to install it in Windows.

For the Linux version, try to use version 7.x, preferably version 7.6 or 7.8.

Go to the official website to find the instructions

image.png

Select the PGSQL version and the Linux distribution version

image.png

Once you get the command, don’t worry about it, just throw it into Linux and run it.

# 下载PGSQL的rpm包
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# 安装PGSQL12的软件程序,需要下载,需要等一会,一般不会失败,即便失败,他也会重新帮你找镜像
sudo yum install -y postgresql12-server

# 数据库初始化
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb

# 设置开启启动项,并设置为开启自行启动
sudo systemctl enable postgresql-12

# 启动PGSQL
sudo systemctl start postgresql-12

This kind of fool-proof installation under Windows is basically error-free. If something goes wrong, it could be:

  • When installing Linux, be sure to choose the minimal installation
  • Your Linux cannot connect to the external network
  • Port 5432 in Linux may be occupied

PostgreSQL does not recommend using root management. After postgreSQL is successfully installed, it will create a user for you by default: postgres.

Before playing with PGSQL, switch to postgres first

su postgres

After switching to the postgres user, directly enter psql to enter the client provided by postgreSQL

# 进入命令行
psql
# 查看有哪些库,如果是新安装的,有三个库,一个是postgres,template0,template1
\l  (字母L小写)

Secondly, it is not recommended to download the Windows version to play.

If you must download: https://sbp.enterprisedb.com/getfile.jsp?fileid=1258242

Guess you like

Origin blog.csdn.net/a772304419/article/details/132921662