Wednesday, June 25, 2014

Logging into the database (Oracle 11g)

After successful installation of the database system, users often have problem in logging into the database, I too had similar kind of problems when I tried to log in as SYS with the same password as I had set at the time of installation for SYS user, using SQL *Plus ( a default client-server tool in the oracle package ). Tried out every variant of the sqlplus command from the command prompt, 
for example:
sqlplus myusername/mypassword@ORCL
sqlplus myusername/mypassword@Host/ORCL
sqlplus sys/mypassword  as dba
etc. But no luck.

Note:
Help on sqlplus command is available by typing:  
sqlplus -H at the command prompt

But then if we configured Oracle Enterprise Manager Database Control during the installation, we can use it to manage our database. Alternatively, we can use Oracle Enterprise Manager Grid Control to manage our database. To display the Database Control:
  1. We use a Web browser to access the Database Control URL:
    http://host:port/em
    
    
    In this example:
    • host is the name of the computer on which we installed Oracle Database
    • port is the port number reserved for the Database Control during installation
    If we do not know the correct port number to use, we look for the following line in the $ORACLE_HOME/install/portlist.ini file:
    Enterprise Manager Console HTTP Port (db_name) = 1158
    
    
    The installation reserves the first available port from the range 5500 to 5519. For example, if we installed Oracle Database on host xyz, and the Database Control uses port 1158, use the following URL:
    http://xyz:1158/em
    
    
    Oracle Enterprise Manager displays the Database Control login page. 
  2. If the db is accessed from the db server itself http://localhost:1158/em can be used.
  3. We Log in to the database using the user name SYS and connect as SYSDBA.
    We Use the password that we have specified for the SYS account during the installation.
 As we log in we see something like this.




We go to Server >> Security >> Users to get the below screen



Now we change the password for the problematic account and check if the account is expired and locked. We can do almost anything to a user account if logged in as a sysdba, e.g. delete, create, set roles and permissions, mark locked assign a temporary table space and so on.


After resetting the SYS password from here, now when we try logging in from the SQL *Plus, it works like a magic.

Unlocking, setting a new password, or granting privileges to other user accounts can be done from OEM db control or from the command prompt while logged in as sysdba. Like
  1. SQL> CONNECT SYS/SYS_password AS SYSDBA
    
  2. SQL> ALTER USER account [ IDENTIFIED BY password ] ACCOUNT UNLOCK;

No comments:

Post a Comment