如何在多个 Oracle 数据库中更改密码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1890310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 19:39:29  来源:igfitidea点击:

How do I change my password in multiple Oracle databases?

oraclepasswords

提问by volni

Is there a tool that allows me to change my password in multiple Oracle databases?

是否有允许我在多个 Oracle 数据库中更改密码的工具?

It expires every month and I would like to change them all simultaneously.

它每个月到期,我想同时更改它们。

采纳答案by volni

I found a good utility for this here: http://www.bsutils.com/PassAid.html.

我在这里找到了一个很好的实用程序:http: //www.bsutils.com/PassAid.html

回答by Jim Hudson

Sometimes, simplest may be best. Create a SQL*Plus script with substitution variables that looks like:

有时,最简单的可能是最好的。使用如下所示的替换变量创建一个 SQL*Plus 脚本:

connect myuser/&&oldpass@db1;
alter user myuser identified by &&newpass replace &&oldpass;
connect myuser/&&oldpass@db2;
alter user myuser identified by &&newpass replace &&oldpass;
connect myuser/&&oldpass@db3;
alter user myuser identified by &&newpass replace &&oldpass;
-- and so forth through your list of instances

(Of course, you'd replace "myuser" with your userid and "db1" and so forth with your SQL*Net aliases.) Build the script. Run it, entering the old and new passwords once, and it will change them all. You'll need to edit the script every time you add or remove a database, but that should be fairly rare. Note that the passwords will be visible on-screen while it's running.

(当然,您可以将“myuser”替换为您的用户 ID,将“db1”等替换为您的 SQL*Net 别名。)构建脚本。运行它,输入一次旧密码和新密码,它将全部更改。每次添加或删除数据库时都需要编辑脚本,但这应该很少见。请注意,密码将在运行时在屏幕上可见。

回答by Philip Schlump

You could change your password in 1 database (I haven't done this in a number of years - so try this carefully - Last time I did this was 7.3.4 and 8i) then copy the hash from database to database. This used to work. So ... In database 1

您可以在 1 个数据库中更改密码(我已经很多年没有这样做了 - 所以请仔细尝试 - 上次我这样做是 7.3.4 和 8i),然后将哈希从数据库复制到数据库。这曾经奏效。所以......在数据库1中

SQL> password
Changing password for SCOTT
Old password:
New password:
Retype new password:

Then in the same database

然后在同一个数据库中

SQL> SELECT password FROM dba_users WHERE  username='SCOTT';
PASSWORD
--------------- 
F81184D39902C27

Now go to the other database and alter that password in:

现在转到另一个数据库并在以下位置更改密码:

SQL> ALTER USER scott IDENTIFIED BY VALUES 'F81184D39902C27';
User altered.

You could write a small program that would connect and to the multiple alters. I only have an 11i database to test this on.

您可以编写一个小程序来连接并连接到多个更改。我只有一个 11i 数据库来测试这个。

回答by Adam Hawkes

I would say if you have to login to multiple databases with the same credentials you should probably have your authentication use some other options, including LDAP/Active Directory.

我想说的是,如果您必须使用相同的凭据登录到多个数据库,您可能应该让您的身份验证使用其他一些选项,包括 LDAP/Active Directory。

回答by J. Chomel

If your password are all the same on each DB, you also have this simple unix shell script:

如果您在每个数据库上的密码都相同,那么您还有这个简单的 unix shell 脚本:

#!/bin/bash
read -p " Enter Username :" USERNAME  ; echo
read -p " Enter old Password :" -s oldpass ; echo
read -p " Enter new Password :" -s newpass ; echo
read -p " Repeat new Password :" -s newpass2 ; echo

if [ "${newpass}" = "${newpass2}" ] 
then
  sqlplus "${USERNAME}"/${oldpass}@db1  << _EOF
         connect "${USERNAME}"/${oldpass}@db1;
      alter user "${USERNAME}" identified by ${newpass} replace ${oldpass};
         connect "${USERNAME}"/${oldpass}@db2;
      alter user "${USERNAME}" identified by ${newpass} replace ${oldpass};
         connect "${USERNAME}"/${oldpass}@db3;
      alter user "${USERNAME}" identified by ${newpass} replace ${oldpass};
_EOF
else 
   echo "given new passwords did not match".
fi

Hope it helps.

希望能帮助到你。

回答by Sawpiece

You can create a repeating list of all you databases:

您可以创建所有数据库的重复列表:

    sqlplus <username>/<oldpass>@<database>;
    alter user <username> identified by <newpass>;
    exit
    --Repeat this for as many databases as you need

OR

或者

You can create a table of all your desired databases and then create a parameter for the databases. Then draw your database name to have it read from the table.

您可以创建一个包含所有所需数据库的表,然后为这些数据库创建一个参数。然后绘制您的数据库名称以从表中读取它。

回答by Rand

If you have Oracle grid control on your systems, you can create a job (within jobs, and then create sql job), and specify a target group (if defined) or manually choose which target databases to connect to via a checklist, and then run that job against these databases.

如果您的系统上有 Oracle 网格控制,您可以创建作业(在作业内,然后创建 sql 作业),并指定目标组(如果已定义)或通过清单手动选择要连接的目标数据库,然后针对这些数据库运行该作业。