In this blog post, I will describe the detailed steps to change the SYS password in an Oracle 19c Docker container. If you have forgotten the system password, instead of reinstalling the entire database, I will show you how to easily reset the password.
This guide assumes that the Oracle database is installed on a Docker container.
Step 1: Access the Docker Container
To enter the Docker container, we first need to find the name of the Docker container and open it. This can be achieved using the following command:
- docker exec: This command allows you to run a command in a running container.
- -it: This option allows interaction with the container via the command line. The
-i
flag keeps the STDIN open even if not attached, and the-t
flag allocates a pseudo-TTY. - database: This is the name of the container. Make sure to use the correct name of your container. You can list all running containers with
docker ps
to find the correct name or ID.
Example command to list running containers:
In this example, the container name is
database
.Step 2: Change the SYS Password
2.1 Start SQL*Plus and Log in as SYSDBA
Once the Docker container is open, we can start SQL*Plus and log in as SYSDBA. No password is required for this:
- sqlplus: This is the command to start SQLPlus, the Oracle database client tool. SQLPlus is a command-line tool that provides an interface to the Oracle Database.
- / as sysdba: This logs us in as SYSDBA, which grants full administrative rights on the database. SYSDBA is a special administrative privilege that allows you to perform high-level administrative tasks.
2.2 Set the Session to the CDB Root Container
To change the password in the correct context, we set the session to the CDB root container. In a multitenant architecture, the root container (CDB$ROOT) contains the Oracle metadata and common users.
- ALTER SESSION SET CONTAINER: This command changes the current container context. It allows you to switch between different containers (PDBs) within the CDB.
- CDB$ROOT: This is the root container in a Container Database (CDB) that contains all Pluggable Databases (PDBs). The root container holds the common data and metadata for the entire CDB.
2.3 Change the Password for the SYS User
Now we can assign a new password for the SYS user. Replace
abc234
with your desired password:- ALTER USER: This command changes the properties of a user. It is used to modify user attributes, including the password.
- sys: This is the user whose password we want to change. The SYS user is the default superuser in Oracle databases.
- IDENTIFIED BY: This specifies the new password. The password should follow the security policies of your organization, including length and complexity requirements.
2.4 Commit the Change and End the Session
Finally, we commit the change and end the session:
- commit: This command confirms all changes made in the current transaction. It makes the changes permanent in the database.
After these steps, the password for the SYS user is successfully changed.
We have now successfully reset the system password and can log in as usual with the new password.
Additional Tips
- Security: Always ensure that the new password is strong and follows your organization's security policies. A strong password typically includes a mix of uppercase and lowercase letters, numbers, and special characters.
- Backup: Before making any changes to the database, it is a good practice to take a backup. This ensures that you can restore the database to its previous state in case something goes wrong.
- Documentation: Document the change in your system's change management records. This helps in tracking changes and troubleshooting issues in the future.
Calls to Action:
- Try it out: Follow the steps to change the SYS password in your Oracle 19c Docker container.
- Share your feedback: Let us know if this guide was helpful and if you need further assistance.
- Stay informed: Subscribe to our blog for more useful guides and tips.
{fullWidth}
0 $type={blogger}:
Kommentar veröffentlichen