[TIL][SQL]서버에 접속하기

goaswon·2020년 10월 28일
0

SQL

목록 보기
1/10

오라클 프로그램을 설치하면 Oracle Server 안에 관리자용 계정인 SYS,SYSTEM계정과 연습할 때 사용하는 연습용 계정인 SCOTT이라는 계정이 생성된다.

C:\Users\user>sqlplus scott/tiger

SQL*Plus: Release 11.2.0.1.0 Production on1026 15:34:46 2020

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

다음에 접속됨:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

데이터베이스가 종료되어 있어서 연습용 계정으로 접속이 안되고 에러가 나는 경우

C:\Users\user>sqlplus scott/tiger

SQL*Plus: Release 11.2.0.1.0 Production on1026 15:34:46 2020

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist

위와같은 에러가 날 경우 아래처럼 사용자명 입력 부분에 관리자용 계정인 sys 계정을 입력하여 접속하고, startup 명령으로 DB를 시작 시킨다.

C:\Users\user>sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on1026 15:40:19 2020

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

사용자명 입력: sys/oracle as sysdba

다음에 접속됨:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

15:40:28 SQL> startup
ORACLE instance started.

Total System Global Area ~~~~~~ bytes
~~~~
~~~~
~~~~
~~~~
Database mounted.
Database opened.
15:40:37 SQL> CONN scott/tiger
Connected.

현재 접속해 있는 계정을 확인 show user명령.

SET sqlprompt "USER>"라는 명령어를 치면 프롬프트의 모양이 현재 접속해 있는 계정 이름으로 변경.

15:43:55 SQL> set sqlpromp "_USER>"
15:44:13 SCOTT>

연습용 계정으로 접속할 때 ORA-28000: the account is locked라는 메시지가 나오는 경우 보안 문제로 연습용 계정인 scott 계정을 사용 못하도록 막아두기 때문. 관리자 계정으로 접속하여 적절한 조치 후 다시 연습용 계정으로 접속.

C:\Users\user>sqlplus scott/tiger

SQL*Plus: Release 11.2.0.1.0 Production on1026 15:34:46 2020

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-28000: the account is locked

Enter user-name: sys/oracle as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS>ALTER USER scott
  2  IDENTIFIED BY tiger
  3  ACCOUNT UNLOCK ;
  
User altered.

SYS>CONN scott/tiger
Connected.
SCOTT>

sys는 오라클에 최고 권한을 가진 계정이고 /뒤의 oraclesys계정의 암호로 오라클을 설치할 때 sys계정의 비밀번호로 지정해 놓은 것이다. 만약 다른 비빌번호를 설정했다면 그 비밀번호를 입력하면 된다.

profile
goaswon

0개의 댓글