【星海随笔】PgSQL安装篇

PostgreSQL安装
Berkley Postgres Project
PostgreSQL

官网网站:http://postgresql.org/download/linux/redhat
基础信息:
OS: Rocky Linux  -  rocky8.7
PgSQL version: 13.6

检查防火墙 systemctl status firewalld

PgSQL

# Install the repository RPM:
sudo dnf install -y \
https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Disable the built-in PostgreSQL module:
sudo dnf -qy module disable postgresql

# Install PostgreSQL:
sudo dnf install -y postgresql13-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13

检查

systemctl status postgresql-13
systemctl status mysqld

提供外部接口
cat /etc/passwd 有这个postgres用户

#su - postgres
su postgres
whoami  【这个用户不需要密码】

#进入数据库
psql

修改postgresql的密码
ALTER USER postgres WITH PASSWORD 'xxx';

登录

psql -h localhost -p 5432 -U postgres
>Password for user postgres:

cd /var/lib/pgsql/13/data/
>* pg_hba.conf
>* postgresql.conf

pg_hba.conf

86 # IPv4 local connections
87 host all all 0.0.0.0/0 scram-sha-256
88 # Allow access remote to login

postgresql.conf

60 listen_addresses = '*'

postgresql常用命令

# 重启服务
systemctl restart postgresql-13

# 访问数据库
psql -h localhost -p 5432 -U postgres

# 创建数据库
CREATE DATABASE my_db;

# 选中数据库
\c my_db

# 建表
CREATE TABLE t_user(
  id INT PRIMARY KEY NOT NULL,
  name  TEXT NOT NULL,
  age   INT  NOT NULL,
  gender  CHAR(10),
  salary  REAL
);

# 查询
select * from t_user;

在这里插入图片描述
配置文件参考文献:
https://www.postgresql.org/docs/11/runtime-config-connection.html#RUNTIME-CONFIG-CONNECTION-SETTINGS
注意:对应的版本不支持网页打开,需要下载到本地

https://www.postgresql.org/docs/release/13.6/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值