ubuntu操作postgres数据库简单汇总如下:
1.安装
2.基本操作
3.创建用户
4.修改密码

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
32
33
34
35
36
37
38
39
#1.安装
    #安装服务器及客户端
    sudo apt-get install postgresql postgresql-client
#2.基本操作
    #查看状态
    sudo /etc/init.d/postgresql status

    #启动
    sudo /etc/init.d/postgresql start

    #停止
    sudo /etc/init.d/postgresql stop

    #重启
    sudo /etc/init.d/postgresql restart
#3.创建用户
#4.修改密码
    #查看配置文件位置
    find / -name pg_hba.conf

    #编辑配置文件
    vi  /etc/postgresql/14/main/pg_hba.conf
    #将 local all postgres md5/peer 修改为 local all postgres trust

    #重启postgres
    sudo /etc/init.d/postgresql restart

    #无密码登录
    psql -U postgres

    #设置密码
    ALTER USER postgres WITH PASSWORD 'postgres';

    #修改配置文件,将trust改为md5
   
    #重启postgres
    sudo /etc/init.d/postgresql restart

    #用正常密码登录

作者 菜园君