关于SQLNET.AUTHENTICATION_SERVICES验证方式的说明
今天去客户那里巡检,客户提出为了提高数据库安全性考虑,需要修改sys/system密码,并通过数据库验证方式来取代默认的操作系统方式,现在我来把这两种验证方式总结一下。 操作系统验证,即通过操作系统账户的权限访问数据库,举个例子,如果已经拥有了windows
今天去客户那里巡检,客户提出为了提高数据库安全性考虑,需要修改sys/system密码,并通过数据库验证方式来取代默认的操作系统方式,现在我来把这两种验证方式总结一下。操作系统验证,即通过操作系统账户的权限访问数据库,举个例子,如果已经拥有了windows下的系统管理员administrator的权限,那么当采用该方式验证的话,无需输入用户/密码就可以访问,比如:sqlplus / as sysdba;哪怕是任意输入的用户名和密码,也无所谓,比如:sqlplus abc/efg as sysdba;
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:02:25 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> exit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开
C:\Documents and Settings\Administrator>sqlplus abc/efg as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:02:33 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
当然,这仅限于sys用户,对于其他用户,哪怕是system,也是必须输入用户名和密码才能访问数据库的
C:\Documents and Settings\Administrator>sqlplus system/123456
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:05:07 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-01017: 用户名/口令无效; 登录被拒绝
请输入用户名:
我的环境中,默认sys和system用户的密码都是"oracle",数据库sys用户的密码,是存放在PWD
SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP
------------------------------ ----- -----
SYS TRUE TRUE
显然,对于采用操作系统验证来访问数据库,安全性还是有一定隐患的,通常在大公司,SA和DBA都是分权管理的,如果数据库因为采用了操作系统验证方式,而使SA可以随意访问数据库那也是不太合适的。基于这种场景,那么我们就可以采用数据库验证方式来限制sys用户必须输入正确的用户名和密码才能够访问数据库。这样的话,当SA没有DBA的sys密码,就无法访问数据库了。
在windows中,是通过sqlnet.ora这个文件来实现验证机制控制的,当你装完数据库并用netca创建了监听,就会生成这个文件,通常默认是以下内容:
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file won't exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES = (NTS)
也就是说,默认就是采用操作系统验证的,也许Oracle认为,拥有了SA权限,就拥有了系统最高权限,所以数据库DBA的sys用户也无需再验证密码了
如果设置成(NONE),就表示采用数据库身份验证,还可以设置成(NONE,NTS),其实这样设也没有意义了,只要括号中有NTS,就会采用操作系统验证,NONE就没有用了
这里要指出一点,有些文章中说还可以设置成(ALL),但我设计测试下来,如果设置成(ALL),会提示ERROR:C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:26:06 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12641: 验证服务无法初始化
请输入用户名:
如,以下这段描述:
Use the parameter SQLNET.AUTHENTICATION_SERVICES to enable one or more authentication services.
If authentication has been installed,it is recommended that this parameter be set to either none or to one of the authentication methods.
NONE for no authentication methods. A valid username and password can be used to access the database.
ALL for all authentication methods
NTS for Windows NT native authentication(An authentication method that enables
a client single login access to a Windows NT server and a database running on the server)
虽然这里说到了有ALL,不过我亲自测试过,确实不行,也许和版本有关,我的版本是10.2.0.1 windows 32bit的
--修改为(NONE)后登陆
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:50:49 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-01031: 权限不足
请输入用户名: sys as sysdba
输入口令: --此处输入正确的密码“oracle”
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
--断开连接,把(NONE)改为(NTS)直接连接SQL> disc
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开
SQL> conn abc/123 as sysdba
ERROR:
ORA-01031: 权限不足
由于没有退出SQLPLUS,刚才改的(NTS)还未生效,可见sqlnet.ora文件是在进入SQLPLUS时才去读取的
--仍然保持(NTS),退出SQLPLUS后重新登陆
SQL> exit
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:54:52 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
现在又是操作系统验证了
注意,如果改成(NONE)以后,当使用RMAN时,system用户就不能操作了,输入正确的密码也不行,只有sys用户并输入密码才可以,测试如下:
--设置为(NTS)的时候登陆RMAN
C:\Documents and Settings\Administrator>rman target /
恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:02:07 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到目标数据库: ORCL10G (DBID=1041171248)
RMAN> exit
恢复管理器完成。
C:\Documents and Settings\Administrator>rman target system/oracle
恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:02:33 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到目标数据库: ORCL10G (DBID=1041171248)
RMAN> exit
恢复管理器完成。
--修改为(NONE)后,再用密码登陆一次RMAN
C:\Documents and Settings\Administrator>rman target system/oracle --注意,这里密码是正确的
恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:03:06 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: 内部恢复管理器程序包初始化失败
RMAN-04005: 目标数据库中存在错误:
ORA-01031: 权限不足
C:\Documents and Settings\Administrator>rman target /
恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:08:47 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: 内部恢复管理器程序包初始化失败
RMAN-04005: 目标数据库中存在错误:
ORA-01031: 权限不足
C:\Documents and Settings\Administrator>rman target sys/oracle
恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:03:16 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到目标数据库: ORCL10G (DBID=1041171248)
RMAN>
很显然,在采用数据库身份验证以后,system用户被禁止使用RMAN了,只有拥有数据库最高权限的sys用户,才能登陆RMAN,而且必须是输入密码的方式登陆
总结:
在windows下,SQLNET.AUTHENTICATION_SERVICES必须设置为NTS才能使用OS认证,不设置(如,把该行语句加#注释符号)或者设置为其他任何值都不能使用OS认证。
主要是以下几种情况:
1. sqlnet.ora文件为空,或用#注释掉 --基于Oracle密码文件验证
2. SQLNET.AUTHENTICATION_SERVICES = (NTS) --基于操作系统验证
3. SQLNET.AUTHENTICATION_SERVICES = (NONE) --基于Oracle密码文件验证
4. SQLNET.AUTHENTICATION_SERVICES = (NONE,NTS) --基于操作系统验证(前后顺序颠倒也一样)
注意:默认情况下,Unix/Linux下的sqlnet.ora文件是没有SQLNET.AUTHENTICATION_SERVICES参数的,似乎连sqlnet.ora这个文件也没有,这和windows有很大的不同
此时是操作系统验证和Oracle密码验证并存,如果加上SQLNET.AUTHENTICATION_SERVICES这个参数后,不管是设置为(NONE)、(NTS)或(NONE,NTS),都是基于Oracle密码验证。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.
