当前位置:网站首页>MacOS下postgresql(pgsql)数据库密码为什么不需要填写或可以乱填写
MacOS下postgresql(pgsql)数据库密码为什么不需要填写或可以乱填写
2022-08-01 09:46:00 【石头StoneWang】
背景
MacOS下postgresql(pgsql)数据库密码似乎可以不填或乱填都可以登录,这个是因为安全策略认为本地连接是安全的,默认配置如此。
然后你会发现无密码登录后执行以下修改postgres用户的密码并重启pgsql进程后,依然不需要密码
ALTER USER postgres WITH PASSWORD '新密码';
如何设置密码
要求改 pg_hba.conf 这个配置文件
配置文件在哪里?
执行 ps -ef|grep postgres,看到
501 3925 1 0 9:01AM ?? 0:00.03 /Applications/Postgres.app/Contents/Versions/12/bin/postgres -D /Users/stonewang/Library/Application Support/Postgres/var-12 -p 5432
501 3927 3925 0 9:01AM ?? 0:00.00 postgres: checkpointer
501 3928 3925 0 9:01AM ?? 0:00.03 postgres: background writer
501 3929 3925 0 9:01AM ?? 0:00.01 postgres: walwriter
501 3930 3925 0 9:01AM ?? 0:00.01 postgres: autovacuum launcher
501 3931 3925 0 9:01AM ?? 0:00.04 postgres: stats collector
501 3932 3925 0 9:01AM ?? 0:00.00 postgres: logical replication launcher
501 3940 3925 0 9:01AM ?? 0:00.01 postgres: postgres postgres 127.0.0.1(58351) idle
501 4074 3637 0 9:10AM ttys001 0:00.00 grep --color postgres
StoneMakPro2019:var-12 stonewang$
看到 -D 后面的路径就是配置文件的目录
进入这个目录/Users/stonewang/Library/Application Support/Postgres/var-12,注意中间有空格要加\转义一下,进入后vi修改配置文件
(下图,本来全是trust的值,全部改成password)
至此,再重启pgsql的进程,然后发现本地连接也需要输入密码了。
边栏推荐
- Naive Bayes--Study Notes--Basic Principles and Code Implementation
- [Interview: Concurrency 39: Multithreading: Thread Pool] ThreadPoolExecutor Class - Submit, Stop
- VS“无法查找或打开PDB文件”是怎么回事?如何解决
- MTK6225-紧急电话
- How to query database configuration parameters in GBase 8c, such as datestyle
- Node's traditional and advanced practices for formatting time (moment)
- MySQL 必现之死锁
- 实验。。。。
- 【Untitled】
- 对于小应用来讲,使用哪款数据库比较好?
猜你喜欢
随机推荐
[Software Architecture Mode] The difference between MVVM mode and MVC mode
【软件架构模式】MVVM模式和MVC模式区别
AI篮球裁判火了,走步算得特别准,就问哈登慌不慌
Explain / Desc 执行计划分析
notes....
Node's traditional and advanced practices for formatting time (moment)
Analysis of High Availability Solution Based on MySql, Redis, Mq, ES
Visualization - Superset installation and deployment
Leicester Weekly 304 6135. The longest ring in the picture Inward base ring tree
阿里腾讯面试一二
In the background of the GBase 8c database, what command is used to perform the master-slave switchover operation for the gtm and dn nodes
C语言小游戏——扫雷
Enterprise WeChat group: robot timing reminder function database configuration
Static Pod, Pod Creation Process, Container Resource Limits
What's up with VS "Cannot find or open PDB file"?How to solve
Introduction and application of heap memory (including examples)
Three chess (C language implementation)
如何保证数据库与缓存数据一致性?
微信公众号授权登录后报redirect_uri参数错误的问题
Get the Token from the revised version of Qubutu Bed









