欢迎来到代码驿站!

PostgreSQL

当前位置:首页 > 数据库 > PostgreSQL

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

时间:2021-03-10 09:23:59|栏目:PostgreSQL|点击:

PostgreSQL登录

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

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表示退出数据库

修改密码

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

alter user pguser with password 'new password';

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

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

[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=#

上一篇:CentOS 7下安装PostgreSQL 9.6的教程分享

栏    目:PostgreSQL

下一篇:pg中replace和translate的用法说明(数据少的中文排序)

本文标题:PostgreSQL 实现登录及修改密码操作

本文地址:http://www.codeinn.net/misctech/77721.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有