0

0

Oracle wallet实现无需输入用户名与密码登陆数据库

php中文网

php中文网

发布时间:2016-06-07 17:57:59

|

2063人浏览过

|

来源于php中文网

原创

在Oracle 10G前,我们在SHELL或JDBC中连接数据库时,都需要输入用户名与密码,并且都是明文。从1OGR2开始,ORACLE提供wallet这个工具,可以实现无需输入用户名与密码就可以登陆数据库,如下: 一般情况:sqlplus scott/Oracle@htzdg 用wallet后:sqlplus /@ht

在Oracle 10G前,我们在SHELL或JDBC中连接数据库时,都需要输入用户名与密码,并且都是明文。从1OGR2开始,ORACLE提供wallet这个工具,可以实现无需输入用户名与密码就可以登陆数据库,如下:

一般情况:sqlplus scott/Oracle@htzdg

用wallet后:sqlplus /@htzdg

测试环境:


server :solaris 10,Oracle 11gr2

client :win 7,Oracle11gr2

登陆端配置tnsnames.ora文件,增加下面几行

HTZDG =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.30)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = htzdg)
    )
  )
测试是否可以正常解析

C:\Users\luoping>tnsping htzdg

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 29-8月 -
2012 21:40:40

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

已使用的参数文件:
D:\app\luoping\product\11.2.0\client_1\network\admin\sqlnet.ora


已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.1
68.100.30)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = h
tzdg)))
OK (40 毫秒)

C:\Users\luoping>
下面是开始配置wallet

    1,创建一个wallet
D:\app\luoping\product\11.2.0\client_1\BIN>mkstore -wrl D:\app\luoping\product\11.2.0\client_1\pstore -create
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。
输入口令:
再次输入口令:
D:\app\luoping\product\11.2.0\client_1\BIN>cd ../
D:\app\luoping\product\11.2.0\client_1>cd pstore
D:\app\luoping\product\11.2.0\client_1\pstore>dir
驱动器 D 中的卷是 DATA
卷的序列号是 D60C-09BD
D:\app\luoping\product\11.2.0\client_1\pstore 的目录
2012/08/29  15:39              .
2012/08/29  15:39              ..
2012/08/29  15:39             3,589 cwallet.sso
2012/08/29  15:39             3,512 ewallet.p12
               2 个文件          7,101 字节
               2 个目录 368,717,893,632 可用字节
   2,启动wallet与指定wallet位置

D:\app\luoping\product\11.2.0\client_1\network\admin>more sqlnet.ora
# sqlnet.ora Network Configuration File: D:\app\luoping\product\11.2.0\client_1\
network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=D:\app\luoping\product\11.2.0\client_1\pstore)))
SQLNET.WALLET_OVERRIDE=TRUE
     3,增加需要登陆的网络服务名,用户,密码到wallet中

D:\app\luoping\product\11.2.0\client_1\BIN>mkstore -wrl D:\app\luoping\product\1
1.2.0\client_1\pstore -createCredential htzdg sys Oracle
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。

输入 Wallet 口令:

Create credential Oracle.security.client.connect_string1
     4,测试是否成功

D:\app\luoping\product\11.2.0\client_1\BIN>sqlplus /@htzdg as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 8月 29 17:48:27 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
    5,查看wallet中配置的网络服务名

D:\app\luoping\product\11.2.0\client_1\BIN>mkstore -wrl d:\app\luoping\product\1
1.2.0\client_1\pstore -listCredential
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。

输入 Wallet 口令:

List credential (index: connect_string username)
1: htzdg sys
    6,一个网络服务名,只能对应一个用户,如果相同的数据库有多少用户需要在同一个client通过wallet实现时,我们需要每一个用户,创建一个网络服务名。

    下面是测试一个网络服务名,相增加两个用户时,报错。

C:\Users\luoping>mkstore -wrl D:\app\luoping\product\11.2.0\client_1\pstore -cre
ateCredential htzdg scott Oracle
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。

输入 Wallet 口令:

Create credential 出现密钥存储错误: Oracle.security.pki.OracleSecretStoreExcepti
on: Credential already exists
     7,当密码修改后,要手动更新wallet中相应的密码。不然要报错的。

D:\app\luoping\product\11.2.0\client_1\BIN>sqlplus /@htzdg as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 8月 29 17:45:56 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL> alter user sys identified by htz;

用户已更改。

SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断


D:\app\luoping\product\11.2.0\client_1\BIN>sqlplus /@htzdg as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 8月 29 17:46:25 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied


请输入用户名:

D:\app\luoping\product\11.2.0\client_1\BIN>mkstore -wrl D:\app\luoping\product\1
1.2.0\client_1\pstore -modifyCredential htzdg sys
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。

命令行中缺少您的密钥/口令
请输入您的密钥/口令:

请重新输入您的密钥/口令:

输入 Wallet 口令:

Modify credential
Modify 1

D:\app\luoping\product\11.2.0\client_1\BIN>

D:\app\luoping\product\11.2.0\client_1\BIN>mkstore -wrl D:\app\luoping\product\1
1.2.0\client_1\pstore -modifyCredential htzdg sys
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。

命令行中缺少您的密钥/口令
请输入您的密钥/口令:

请重新输入您的密钥/口令:

输入 Wallet 口令:

Modify credential
Modify 1

D:\app\luoping\product\11.2.0\client_1\BIN>
D:\app\luoping\product\11.2.0\client_1\BIN>sqlplus /@htzdg as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 8月 29 17:48:27 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
     8,手动删除wallet中的记录

D:\app\luoping\product\11.2.0\client_1\BIN>mkstore -wrl d:\app\luoping\product\1
1.2.0\client_1\pstore -deleteCredential htzdg
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。

输入 Wallet 口令:

Delete credential
Delete 1
     9,mkstore命令帮忙手册

D:\app\luoping\product\11.2.0\client_1\BIN>mkstore
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版权所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有权利。

mkstore [-wrl wrl] [-create] [-createSSO] [-createLSSO] [-createALO] [-delete] [
-deleteSSO] [-list] [-createEntry alias secret] [-viewEntry alias] [-modifyEntry
alias secret] [-deleteEntry alias] [-createCredential connect_string username p
assword] [-listCredential] [-modifyCredential connect_string username password]
[-deleteCredential connect_string] [-help] [-nologo]

相关专题

更多
苹果官网入口直接访问
苹果官网入口直接访问

苹果官网直接访问入口是https://www.apple.com/cn/,该页面具备0.8秒首屏渲染、HTTP/3与Brotli加速、WebP+AVIF双格式图片、免登录浏览全参数等特性。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

115

2025.12.24

拼豆图纸在线生成器
拼豆图纸在线生成器

拼豆图纸生成器有PixelBeads在线版、BeadGen和“豆图快转”;推荐通过pixelbeads.online或搜索“beadgen free online”直达官网,避开需注册的诱导页面。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

82

2025.12.24

俄罗斯搜索引擎yandex官方入口地址(最新版)
俄罗斯搜索引擎yandex官方入口地址(最新版)

Yandex官方入口网址是https://yandex.com。用户可通过网页端直连或移动端浏览器直接访问,无需登录即可使用搜索、图片、新闻、地图等全部基础功能,并支持多语种检索与静态资源精准筛选。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

546

2025.12.24

JavaScript ES6新特性
JavaScript ES6新特性

ES6是JavaScript的根本性升级,引入let/const实现块级作用域、箭头函数解决this绑定问题、解构赋值与模板字符串简化数据处理、对象简写与模块化提升代码可读性与组织性。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

150

2025.12.24

php框架基础知识汇总
php框架基础知识汇总

php框架是构建web应用程序的架构,提供工具和功能,以简化开发过程。选择合适的框架取决于项目需求和技能水平。实战案例展示了使用laravel构建博客的步骤,包括安装、创建模型、定义路由、编写控制器和呈现视图。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

20

2025.12.24

Word 字间距调整方法汇总
Word 字间距调整方法汇总

本专题整合了Word字间距调整方法,阅读下面的文章了解更详细操作。

47

2025.12.24

任务管理器教程
任务管理器教程

本专题整合了任务管理器相关教程,阅读下面的文章了解更多详细操作。

7

2025.12.24

AppleID格式
AppleID格式

本专题整合了AppleID相关内容,阅读专题下面的文章了解更多详细教程。

12

2025.12.24

csgo视频观看入口合集
csgo视频观看入口合集

本专题整合了csgo观看入口合集,阅读下面的文章了知道更多入口地址。

371

2025.12.24

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
SQL 教程
SQL 教程

共61课时 | 3.1万人学习

Java 教程
Java 教程

共578课时 | 37.5万人学习

oracle知识库
oracle知识库

共0课时 | 0人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号