HGDB不知道数据库用户密码的情况下,新库使用原密码创建该用户(适用于postgres)
2017-09-15 14:39
609 查看
通过如下方式先查询角色及密码:
highgo=# \d pg_authid
Table "pg_catalog.pg_authid"
Column | Type | Modifiers
----------------+--------------------------+-----------
rolname | name | not null
rolsuper | boolean | not null
rolinherit | boolean | not null
rolcreaterole | boolean | not null
rolcreatedb | boolean | not null
rolcanlogin | boolean | not null
rolreplication | boolean | not null
rolbypassrls | boolean | not null
rolconnlimit | integer | not null
rolpassword | text |
rolvaliduntil | timestamp with time zone |
Indexes:
"pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
"pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
highgo=# select rolname,rolpassword from pg_authid;
rolname | rolpassword
---------+-------------------------------------
highgo |
test | md505a671c66aefea124cc08b76ea6d30bb
(2 rows)
新库中执行如下方法重建新角色:
highgo=# create user test;
CREATE ROLE
highgo=# update pg_authid set rolpassword='md505a671c66aefea124cc08b76ea6d30bb' where rolname='test';
UPDATE 1
highgo=# create user aaa;
CREATE ROLE
highgo=# update pg_authid set rolpassword='md505a671c66aefea124cc08b76ea6d30bb' where rolname='aaa';
UPDATE 1
highgo=# \q
[highgo@hg highgo]$
说明:使用同一个md5密文,需确保新旧数据库的数据库名字必须一致,否则创建的其他的用户名使用此md5密文将无法登录,除非修改密码。
highgo=# \d pg_authid
Table "pg_catalog.pg_authid"
Column | Type | Modifiers
----------------+--------------------------+-----------
rolname | name | not null
rolsuper | boolean | not null
rolinherit | boolean | not null
rolcreaterole | boolean | not null
rolcreatedb | boolean | not null
rolcanlogin | boolean | not null
rolreplication | boolean | not null
rolbypassrls | boolean | not null
rolconnlimit | integer | not null
rolpassword | text |
rolvaliduntil | timestamp with time zone |
Indexes:
"pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
"pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
highgo=# select rolname,rolpassword from pg_authid;
rolname | rolpassword
---------+-------------------------------------
highgo |
test | md505a671c66aefea124cc08b76ea6d30bb
(2 rows)
新库中执行如下方法重建新角色:
highgo=# create user test;
CREATE ROLE
highgo=# update pg_authid set rolpassword='md505a671c66aefea124cc08b76ea6d30bb' where rolname='test';
UPDATE 1
highgo=# create user aaa;
CREATE ROLE
highgo=# update pg_authid set rolpassword='md505a671c66aefea124cc08b76ea6d30bb' where rolname='aaa';
UPDATE 1
highgo=# \q
[highgo@hg highgo]$
说明:使用同一个md5密文,需确保新旧数据库的数据库名字必须一致,否则创建的其他的用户名使用此md5密文将无法登录,除非修改密码。
相关文章推荐
- postgres创建用户,修改用户密码,创建数据库
- 创建表空间以及用户,授予权限,查看表空间名称及大小,物理文件的名称及大小,数据库的创建日期和归档方式,数据库的版本,数据库库对象,表空间的使用情况,表空间读写
- postgres创建用户,修改用户密码,创建数据库
- 不知道密码情况下创建用户 (转)
- 使用Oracle SQLDeveloper连接数据库并创建用户
- 今天操作公司的数据库,出现单个用户使用的情况,解决方案如下
- 使用Oracle SQLDeveloper连接数据库并创建用户
- 创建数据库、表、主外键、各种约束、存储过程、视图、索引、事务使用、触发器、创建登录账号、数据库用户 Sql语句示例
- 请教:怎样用命令行方式创建数据库并指定用户和密码
- 在 mysql 数据库中创建用户和数据库以及修改用户密码
- 在不知道MySQL帐号密码的情况下创建帐号并获得权限
- 计算当前Exchange 2010 数据库的用户使用情况,通过PS命令行!
- 使用Oracle SQLDeveloper连接数据库并创建用户
- Linux 上如何创建新的用户,并让其在首次登陆后修改密码,并限制其允许使用的磁盘空间
- [转]使用Oracle SQL Developer连接数据库并创建用户
- Server系列9:如何知道域用户密码的使用情况?(Done)
- 在Linux下面使用Mysql的客户端工具WorkBench创建数据库和用户并连接
- Linux 创建用户使用-p参数自动设置密码
- 使用Oracle SQLDeveloper连接数据库并创建用户
- 查询数据库中所有用户表的使用情况