centos-pg数据库安装


1、yum install postgresql-server postgresql -y

2、service postgresql initdb # 初始化
3、service postgresql start #启动
4、chkconfig postgresql on
5、# 默认不能用root进入pg的命令行,安装会创建一个用户 postgres
su 切换为 postgres 用户
执行 psql 可以进入pg的命令行
6、配置开启远程登录
cat /var/lib/pgsql/data/pg_hba.conf | grep -v "#"
local all all peer
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
# 所有库,所有用户,从所有地址登陆
host all all 0.0.0.0/0 md5
7、修改监听地址
cat /var/lib/pgsql/data/postgresql.conf | grep -v -E "#|^$"
取消这行的注释:listen_addresses = '*' # 可以放开远程连接

[root@docker-remote2 ~]# su postgres
#切换到postgres用户
# 创建用户aaa ,密码 aaa
postgres=# create user aaa with password ‘aaa’;
CREATE ROLE

# 创建数据库 venus
postgres=# create database venus;
CREATE DATABASE

# 把 venus 库赋给用户 aaa 权限
postgres=# grant all privileges on database venus to aaa;

# 把venus2库属主赋给aaa
postgres=# create database venus2 owner aaa;
CREATE DATABASE

posted on   大兄弟666  阅读(667)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示