개발 교육 일기

파이썬 교육Day12(+mysql에서 데이터베이스 설치하기, select~ from~ where~ order by~ 실습문제, mysql 소스코드 링크 등)

오이띠 2021. 3. 30. 09:51
728x90

오늘은 온라인 교육이었고, 수업내용은 다음과 같다. 

수업 계획

1. mysql에서 employees db 설치하기

 

  a. C:\(로컬디스트 C) 에다가 database를 넣는다. (ex. employees_db.zip 압축을 풀어 넣는다.)

 

  b. DB 및 계정 만들기 (Workbench에서 DBA로 접속한 후(아래 사진 참고))

 

  c. 아래와 같이 친 후, ctrl+enter를 누른다. 

 

 

create database employees;
create user 'employees'@'localhost' identified by 'employees'; #마지막'employees'는 비밀번호
grant all privileges on employees.* to 'employees'@'localhost';
flush privileges;

 

  d. workbench에서 employees계정으로 employees DB 접속해보기

 

위와 같이 작성하고, password부분도 눌러서 비밀번호 누르기. 

Test Connection 먼저 하고 등록한다. 

 

  e. 명령 프롬프트에서 employees_db 파일로 들어가, mysql -u employee -D employee -p < employees.sql 치고 연결한다. 

 

 

 

 

 

 

2. select~ from~ where~ order by~ 등 데이터베이스 개념 

 

3. 데이터베이스로 실습

 

실습문제: 

 

 

01.기본[hr계정_SQL_실습문제].doc
0.04MB

코드: 

 

 

 

 

4. 기타:

   a. 이름 잘지어야돼(관례 지키기)

   b. 자격증: 정보처리기사, SQL 자격증, DA 자격증, Tensorflow 자격증

   c. C:\Program Files\MySQL\MySQL Server 5.1\bin 에 mysql의 .exe 있음

 

 

5. 오류 해결 방법

 

MySQL Workbench에서 위와같이 실행하고, 

 

위 Manage Server Connections를 진행했을 때, 

 

 

'Cannot Connect to Database Server'란 오류가 뜬다면.. 

 

 

 

 

위와같이 명령프롬프트에서 다시 해보면 된다. (root 계정으로 db생성할 때 사용자 권한 설정이 제대로 안되서 생기는 오류같다.)

 

 

코드는..

create database Investar;
create user 'Investar'@'localhost' identified by 'Investar';
grant all privileges on Investar.* to 'Investar'@'localhost';
flush privileges;

728x90