Oracle database environment variable configuration + modify database password

1. Set environment variables:

The environment variable must be set before you can use the CMD command to access the Oracle database

1.1. First find your Oracle installation location path

C:\app\Administrator\product\11.2.0\dbhome_1

 1. 2. Set environment variables

 1.2.1 Setting the Adimistrator variable

Variable name: ORACLE_HOME
Variable value: C:\app\Administrator\product\11.2.0\dbhome_1

1.2.2 Create a new variable home, and add it to the path: %ORACLE_HOME%\BIN

Note: There are many variables in the path, if you add a new one, you need to separate each variable with a ; number!

1.2.3 System variables

Variable name: ORACLE_HOME
Variable value: C:\app\Administrator\product\11.2.0\dbhome_1\BIN

Note: If the monitoring fails after restarting the computer, please change the variable value to C:\app\Administrator\product\11.2.0\dbhome_1 (combined with your own path)

 2. NLS_LANG: Configure the character set of the client (can solve the problem of Chinese garbled characters).
Variable name: NLS_LANG
Variable value: SIMPLIFIED CHINESE_CHINA.ZHS16GBK
View server character set: select userenv('language') from dual;

3. TNS_ADMIN: monitor the database tns, PL/SQL login is necessary to display the database connection information
variable name TNS_ADMIN
variable value XXX:\Oracle\product\11.2.0\dbhome_1\network\admin (your ADMIN directory location )

Note: A few days ago, because the computer restarted, the monitoring failed, and the PLSQLDevelop link to Oracle appeared later.

 I checked all the available information and tried all the methods I could try, but none of them hit the problem

1. checked out

2. Reset the Oracle environment variable (solved the problem of port monitoring)

3. Try PLSQL force link (didn't solve target host problem but close)

4. [The finale] 

 The solution is to reinstall the remote link

tool (default C drive), set environment variables, and modify the tnsnames.ora in the installation directory admin

 

 

1.2.4 Open CMD to test whether the link is successful

CMD command input

Note: Any command prompts you that the executable program cannot be found because the environment variable is not in place

 

sqlplus

Indicates that the database follows the success

Start can use start

Check the status with status 

2. Modify user password

There are the following methods to modify the password of the oracle user:

general user  

(1) Modify by alter user syntax, which is also the most common way:

(2) The second way is to modify through the password command:

From a security point of view, it is recommended that you use the second method to modify the user password , which can prevent the disclosure of the plaintext password.

sys user

In addition, regarding the sys user password, do not use the password and alter user methods to modify it. The main reasons are as follows:

(1) When the REMOTE_LOGIN_PASSWORDFILE parameter is set to shared, when we use alter user to modify the sys password, it will report

ORA-28046: Password change for SYS disallowed error.

The test is as follows:

(2) Most internal recursive SQL uses the SYS user. Therefore, if you try to change this password using the ALTER USER statement while the database is open, it may cause a deadlock.

Therefore, for the sys user we need to use orapwd to modify:

[oracle@orcl dbs]$ orapwd file='orapworcl' entries=5 force=y Note here that there should be no spaces around the equal sign;

About orapwd instructions refer to the official website, as follows:

Argument Description
FILE Name to assign to the password file. You must supply a complete path. If you supply only a file name, the file is written to the current directory.
ENTRIES (Optional) Maximum number of entries (user accounts) to permit in the file.
FORCE (Optional) If  , permits overwriting an existing password file.
IGNORECASE (Optional) If  , passwords are treated as case-insensitive.

Guess you like

Origin blog.csdn.net/leoysq/article/details/130840860