'샘플 데이터베이스'에 해당되는 글 1건

728x90

MySQL 샘플 데이터베이스 설치하는 방법이다.

 

https://www.mysqltutorial.org/mysql-sample-database.aspx

 

MySQL Sample Database

This page provides you with a MySQL sample database that helps you to practice with MySQL effectively and quickly. You can download the sample database and load it into your MySQL Server.

www.mysqltutorial.org

위 사이트에 접속하면 받을 수가 있는데 문제는 Import 하면 에러가 발생하더라.

전체적인 구조는 위와 같다.

 

Legacy Create 테이블 생성 방식(?)이라 그런지 몰라도 테이블 순서가 매우 중요하다.

sql 파일을 Editor로 열어보면, Foreign Key 가 설정되어 있고 employees 테이블을 참조하고 있다.

customer 테이블보다 먼저 employees 테이블이 먼저 Import 되어야 한다는 의미로 간주해야 한다.

CREATE TABLE `customers` (
  `customerNumber` int(11NOT NULL,
  `customerName` varchar(50NOT NULL,
  `contactLastName` varchar(50NOT NULL,
  `contactFirstName` varchar(50NOT NULL,
  `phone` varchar(50NOT NULL,
  `addressLine1` varchar(50NOT NULL,
  `addressLine2` varchar(50DEFAULT NULL,
  `city` varchar(50NOT NULL,
  `state` varchar(50DEFAULT NULL,
  `postalCode` varchar(15DEFAULT NULL,
  `country` varchar(50NOT NULL,
  `salesRepEmployeeNumber` int(11DEFAULT NULL,
  `creditLimit` decimal(10,2DEFAULT NULL,
  PRIMARY KEY (`customerNumber`),
  KEY `salesRepEmployeeNumber` (`salesRepEmployeeNumber`),
  CONSTRAINT `customers_ibfk_1` FOREIGN KEY (`salesRepEmployeeNumber`REFERENCES `employees` (`employeeNumber`)
ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 

 

이런 점을 고려하여 테이블 순서를 변경한 파일을 첨부한다.

mysqlsampledb.sql
0.20MB

 

위 파일을 Import 하면 정상적으로 테이블이 생성되고 데이터가 추가될 것이다.

 

DBWeaver TOOL 을 이용해서 접속해보자.

접속환경 : VirtualBox 기반 CentOS 7.9 MariaDB 10.5

DB IP address : 192.168.1.20 (사설 IP)

Access IP address : 192.168.1.25

 

-- 사용자 권한 부여
-- 비밀번호는 각자 수정하시라.
use mysql;
grant all privileges on cmodels.* to codefox@'192.168.1.25' identified by '비밀번호';
flush privileges;
 

 

 

 

 

'SQL' 카테고리의 다른 글

접속로그 통계 (신규, 중복 동시 처리)  (0) 2023.05.23
MySQL foreign key 예제  (0) 2022.05.16
MariaDB 멀티 인덱스(index) 설정  (0) 2022.04.05
MariaDB 대소문자 구분  (0) 2022.03.14
MySQL 중복 레코드 관리 방법  (0) 2022.03.02
블로그 이미지

Link2Me

,