postgresql数据库的windows安装较为简单,直接去如下的官网
https://www.postgresql.org/download/
下载对应的安装包进行安装即可
而在Linux环境中安装,官网也为每一种操作系统单独进行了安装说明。
以centos为例:
https://www.postgresql.org/download/linux/redhat/
选好系统版本和操作系统后,会自动列出yum安装指令
我这里安装的是postgresql10
1、首先打开终端,cd到自己的临时目录
2、yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
3、yum install postgresql10
4、yum install postgresql10-server
5、yum install postgresql10-client
6、yum install postgresql10-deve/usr/pgsql-10/bin/postgresql-10-setup initd
7、systemctl enable postgresql-10
8、systemctl start postgresql-10
安装完毕后,需要设置一下数据库的用户密码
su - postgres 切换用户
psql -U postgres 登录数据库
ALTER USER postgres WITH PASSWORD '123456' 设置postgres用户密码
\q 退出数据库
这样就安装完毕了。
由于平时还是在windows操作,操作数据库的时候,可以用windows的pgadmin4连接Linux的postgresql数据库