以编程方式更改过期的Oracle DB密码? [英] Programmatically Change Expired Oracle DB Password?

查看:92
本文介绍了以编程方式更改过期的Oracle DB密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我工作的地方,一些数据库从生产环境复制到我们的测试环境,但是DBA在复制后立即在(新)测试DB上将所有密码设置为过期,以使生产密码未知.因此,如果我运行sqlplus并使用特定的用户名连接到测试数据库,它将立即提示我输入新密码.

Where I work, some databases get copied down from our production environment to our test environment, but the DBAs set all the passwords to expired on the (new) test DB right after the copy so that the production passwords are not known. So if I run sqlplus and connect to the test db with a specific username it immediately prompts me for a new password.

是否可以通过Java应用程序或Shell脚本自动为特定用户更改过期的oracle 10g数据库密码?

Is there a way via a java app or shell scripting to automate the changing of an expired oracle 10g database password for a specific user?

推荐答案

在Unix上

如果您使用的是Unix,则可以使用Shell脚本.

On Unix

If you're on unix, you can do with a shell script.

我已经这样测试过了:

drop user foo cascade;
create user foo identified by old_password password expire;
grant create session to foo;
exit

现在使用这个小脚本:

cat <<DOG | sqlplus foo/old_password
    new_password
    new_password
    exit
DOG

并使用小脚本更改密码

sh change_expired_password.sh

然后,更改密码并可以将其连接到实例:

Then, the password is changed and it can be connected to the instance:

sqlplus foo/new_password@ORCL

很显然,您可以将cat ...构造放入适合您的shell脚本中.

Obviously, you would put the cat ... construct in a shell script that suits you.

在Windows上,您可以使用这样的批处理文件

On Windows you could go with a batch file like so

@(
  echo new_password
  echo new_password
) | sqlplus foo/old_password@ORCL

这篇关于以编程方式更改过期的Oracle DB密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆