PostgreSQL 實(shí)現(xiàn)登錄及修改密碼操作
PostgreSQL登錄
1、可通過客戶端pgAdmin III直接登錄
2、可通過命令行
命令:psql -h 10.10.10.10 -U user -d postgres -p 5570
-h:數(shù)據(jù)庫IP
-U:登錄用戶
-d:登錄的數(shù)據(jù)庫
-p:登錄端口
方法:進(jìn)入postgreSQL的客戶端安裝目錄(我的安裝目錄:C:\Program Files\PostgreSQL\9.4\bin),執(zhí)行psql命令,其中\(zhòng)q表示退出數(shù)據(jù)庫
修改密碼
直接執(zhí)行以下sql即可修改密碼
alter user pguser with password 'new password';
補(bǔ)充:PostgreSQL修改密碼認(rèn)證方式
我就廢話不多說了,大家還是直接看代碼吧~
[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=#
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。
相關(guān)文章
基于postgresql查詢某個(gè)字段屬于哪個(gè)表的說明
這篇文章主要介紹了基于postgresql查詢某個(gè)字段屬于哪個(gè)表的說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-01-01Ruoyi從mysql切換到postgresql的幾個(gè)踩坑實(shí)戰(zhàn)
最近由于工作的原因,需要將Ruoyi從mysql切換到postgresql,所以這篇文章主要給大家介紹了關(guān)于Ruoyi從mysql切換到postgresql的幾個(gè)踩坑實(shí)戰(zhàn),需要的朋友可以參考下2023-02-02詳解如何在Ubuntu?18.04上安裝和使用PostgreSQL
關(guān)系數(shù)據(jù)庫管理系統(tǒng)是許多網(wǎng)站和應(yīng)用程序的關(guān)鍵組件,它們提供了一種結(jié)構(gòu)化的方式來存儲(chǔ)、組織和訪問信息,本文演示了如何在?Ubuntu?18.04?VPS?實(shí)例上安裝?Postgres,并提供了基本數(shù)據(jù)庫管理的說明,需要的朋友可以參考下2024-07-07PostgreSQL中date_trunc函數(shù)的語法及一些示例
這篇文章主要給大家介紹了關(guān)于PostgreSQL中date_trunc函數(shù)的語法及一些示例的相關(guān)資料,DATE_TRUNC函數(shù)是PostgreSQL數(shù)據(jù)庫中用于截?cái)嗳掌诓糠值暮瘮?shù),文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-04-04PostgreSQL實(shí)現(xiàn)定期備份的方法
PostgreSQL定期備份功能可以自動(dòng)備份數(shù)據(jù)庫,避免了手動(dòng)備份過程中可能發(fā)生的錯(cuò)誤,也極大地減輕了管理員的工作壓力,所以本文將給大家介紹一下PostgreSQL實(shí)現(xiàn)定期備份的方法,需要的朋友可以參考下2024-03-03如何使用Dockerfile創(chuàng)建PostgreSQL數(shù)據(jù)庫
這篇文章主要介紹了如何使用Dockerfile創(chuàng)建PostgreSQL數(shù)據(jù)庫,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2024-02-02在postgresql中結(jié)束掉正在執(zhí)行的SQL語句操作
這篇文章主要介紹了在postgresql中結(jié)束掉正在執(zhí)行的SQL語句操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-12-12