参考:
https://blog.csdn.net/zhangzeyuaaa/article/details/77941039
https://blog.csdn.net/warrior_0319/article/details/78091949
su - postgres
postgres@ubuntu:~$ psql
查看所有数据库:
postgres=# \l
\c + 数据库名
进入数据库。
参考:https://www.runoob.com/postgresql/postgresql-select-database.html
列出所有用户:
postgres=# \du
\c bitbucket_6_1_1 # 选择数据库
select prop_value from app_property where prop_key = 'license'; # 查询
UPDATE app_property SET prop_value = 'xxx' where prop_key = 'license'; # 重新设置值
参考:
https://www.yiibai.com/postgresql/postgresql-update.html
创建用户、数据库,并授权。
postgres=# create user bitbucket with password 'bitbucket';
CREATE ROLE
postgres=# create database bitbucket_6_1_1 owner bitbucket;
CREATE DATABASE
postgres=# grant all privileges on database bitbucket_6_1_1 to bitbucket;
GRANT
删除数据库:
DROP DATABASE [IF EXISTS] database_name;
程序链接PostgreSQL 时报错"no pg_hba.conf entry"
参考:https://blog.csdn.net/liuchunming033/article/details/44810899
找到对应的pg_hba.conf文件:
在ubuntu 20上是这个文件。
/etc/postgresql/12/main/pg_hba.conf
然后添加postgresql客户端的IP范围:
加一行:
host all all 192.168.85.0/24 md5
在centos上,这个目录是
/var/lib/pgsql/
修改监听IP
/etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
参考:
- https://www.cnblogs.com/wuling129/p/4652025.html
- https://cloud.tencent.com/developer/article/1592808
- 如何使用PostgreSQL列出当前数据库中的表
Windows启动Postgresql
D:\pgsql\data>D:\pgsql\bin\initdb.exe -D
D:\pgsql>bin\pg_ctl.exe start -D D:\pgsql\data
D:\tmp>netstat -ano|findstr 5432
TCP 127.0.0.1:5432 0.0.0.0:0 LISTENING 22216
TCP [::1]:5432 [::]:0 LISTENING 22216