服务器之家

服务器之家 > 正文

PostgreSQL 实现登录及修改密码操作

时间:2021-03-31 17:50     来源/作者:moilbeauty

PostgreSQL登录

1、可通过客户端pgAdmin III直接登录

PostgreSQL 实现登录及修改密码操作

2、可通过命令行

命令:psql -h 10.10.10.10 -U user -d postgres -p 5570

-h:数据库IP

-U:登录用户

-d:登录的数据库

-p:登录端口

方法:进入postgreSQL的客户端安装目录(我的安装目录:C:\Program Files\PostgreSQL\9.4\bin),执行psql命令,其中\q表示退出数据库

PostgreSQL 实现登录及修改密码操作

修改密码

直接执行以下sql即可修改密码

?
1
alter user pguser with password 'new password';

补充:PostgreSQL修改密码认证方式

我就废话不多说了,大家还是直接看代码吧~

?
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
[postgres@postgres_vm ~]$ psql
psql (12.4)
Type "help" for help.
postgres=# show password_encryption ;
 password_encryption
---------------------
 md5
(1 row)
postgres=# select * from pg_authid where rolname='hr';
 oid | rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolbypassrls | rolconnlimit |       r
olpassword       | rolvaliduntil
-------+---------+----------+------------+---------------+-------------+-------------+----------------+--------------+--------------+--------------
-----------------------+---------------
 16386 | hr   | f    | t     | f       | f      | t      | f       | f      |      -1 | md566ad2e6b6f
adaa9fd11bfcab906e84c8 |
(1 row)
postgres=# set password_encryption to "scram-sha-256";
SET
postgres=# select * from pg_authid where rolname='hr';
 oid | rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolbypassrls | rolconnlimit |       r
olpassword       | rolvaliduntil
-------+---------+----------+------------+---------------+-------------+-------------+----------------+--------------+--------------+--------------
-----------------------+---------------
 16386 | hr   | f    | t     | f       | f      | t      | f       | f      |      -1 | md566ad2e6b6f
adaa9fd11bfcab906e84c8 |
(1 row)
postgres=# alter user hr with password 'Abcd1234';
ALTER ROLE
postgres=# select * from pg_authid where rolname='hr';
 oid | rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolbypassrls | rolconnlimit |
                        rolpassword                               | rolvaliduntil
-------+---------+----------+------------+---------------+-------------+-------------+----------------+--------------+--------------+--------------
-------------------------------------------------------------------------------------------------------------------------+---------------
 16386 | hr   | f    | t     | f       | f      | t      | f       | f      |      -1 | SCRAM-SHA-256
$4096:dF5WnZnKGXen0mtqZeWldA==$2K8sshkEarHox93X5hmIjKSPxHecXDkjZ56erjIf+dU=:FBbY3+22nVXF83LbfK6DHBK2QpakJA/0RRI3oXs4cdI= |
(1 row)
postgres=#

以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。如有错误或未考虑完全的地方,望不吝赐教。

原文链接:https://blog.csdn.net/xuemeilu/article/details/67632883

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部