Home  >  Article  >  Database  >  What to do if you forget your oracle sys password?

What to do if you forget your oracle sys password?

PHPz
PHPzOriginal
2023-04-17 14:11:519355browse

In the process of using Oracle database, we will inevitably encounter some problems, such as forgetting the sys password of the administrator account. In this case, we need to take some measures to solve the problem so that we can regain the permissions of the sys account. In this article, we will provide you with some methods and techniques to solve the problem of forgetting Oracle sys password.

1. Use SYSDBA permissions to change the password

  1. Find the SQLPLUS tool of the Oracle client and open the console.
  2. Log in to the database using SYSDBA permissions:
sqlplus / as sysdba
  1. Run the following command to change the password of the sys account:
alter user sys identified by 新密码;

Note: Enter The password will not be displayed. So you need to enter the password first and then press Enter to confirm.

  1. Exit the SQLPLUS client, and then log in again to test whether the modified password can access the database.

2. Use the orapwd tool to reset the SYS password

  1. Open the command line window of the operating system and enter the database directory under the ORACLE_HOME directory.
  2. Run the following command to create a new password file:
orapwd file=sys_password password=新密码 entries=1 force=yes
  1. Log in to the database using the SYSDBA user and run the following command to associate the new password file with the database :
alter system set remote_login_passwordfile='EXCLUSIVE';
  1. Exit the SQLPLUS client, and then log in again to test whether the new file password can access the database.

3. Use SQL*Plus to reset the SYS password

  1. Open the SQL*Plus client.
  2. Log in to SYS user:
sqlplus sys/旧密码 as sysdba
  1. Run the following command to change the new password:
alter user sys identified by 新密码;
  1. Exit SQL*Plus client terminal, and then log in again to test whether the new password can access the database.

Summary:

In general, if we encounter the situation of forgetting the oracle sys password, we can use the above three methods to reset the password. The first method is relatively simple to use SYSDBA permissions to change the password, but it requires the use of SYSDBA permissions; the second method uses the orapwd tool to reset the password file, which is more flexible, but requires the use of the operating system command line; the third method uses SQL*Plus is more convenient to reset the password, but you need to know the old password. Therefore, choose the appropriate method according to your own situation to quickly restore the permissions of the oracle sys account.

The above is the detailed content of What to do if you forget your oracle sys password?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn