Oracle数据库一般通过密码来验证用户连接,用户通过输入密码连接到数据库进行操作。当然也能通过数据库外部方法来验证用户,如操作系统、kerberos或者radius。使用这些方法时,用户无需输入密码即可登陆数据库,这里介绍通过操作系统验证用户登陆数据库。
使用操作系统验证需设置OS_AUTHENT_PREFIX参数,默认OS_AUTHENT_PREFIX=OPS$,即数据库内需创建一个名为OPS$TEST用户,同时操作系统内创建test账户,这样ops$test用户无需密码可直接登录数据库,为了符合通用命名规范,直接将该参数设为null值。
# 设置OS_AUTHENT_PREFIX参数为null值SQL> alter system set os_authent_prefix="" scope=spfile;# 系统已存在test用户,创建数据库test用户SQL> create user test identified externally;SQL> grant connect,resource to test;# 使用test用户登录数据库[test@testdb ~]$ sqlplus /SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 28 20:50:09 2020Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> show user;USER is "TEST"登录成功。
通过设置remote_os_authent参数,远程直接登录数据库
# 设置OS_AUTHENT_PREFIX参数为null值SQL> alter system set remote_os_authent=true scope=spfile;# 本机电脑账户为liuhj,创建数据库liuhj用户SQL> create user liuhj identified externally;SQL> grant connect,resource to liuhj;# 本机直接登录数据库C:\Users\liuhj>sqlplus /@192.168.2.6:1521/testdbSQL*Plus: Release 11.2.0.4.0 Production on 星期一 12月 28 21:06:19 2020Copyright (c) 1982, 2013, Oracle. All rights reserved.连接到:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> show user;USER 为 "LIUHJ"
允许远程用户直接登录数据库存在较大风险,生产环境不建议使用。
文章转载自6号见的MindPalace,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




