설치

MariaDB 10 을 대상으로 진행되었습니다.

  1. 다운로드

    그림 : MariaDB download
    MariaDB download page
  2. unzip

    그림 : MariaDB 압축풀기
    unzip
  3. Run

    mysqld.exe --datadir=..\data --console
    
    그림 : MariaDB 서버 시작
    run
  4. 사용자 추가

    mysql.exe -u root
    use {데이타베이스명};
    create user '{아이디}'@'{호스트}' identified by '{패스워드}';
    grant all privileges on {데이타베이스명}.* to {아이디}@'{호스트}';
    flush privileges;
    
    그림 : MariaDB 사용자 추가
    add user
  5. create database

    mysql.exe -u root
    
    create database sampledb
    use sampledb;
    create user 'user'@'%' identified by 'pass';
    grant all privileges on sampledb.* to user@'%';
    flush privileges;
    
    mysql.exe -u user
    
    use sampledb
    
    CREATE TABLE if not exists DEPT (
        DEPTNO int(2) NOT NULL,
        DNAME varchar(14),
        LOC varchar(13),
        CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO)
    );
    CREATE TABLE if not exists EMP (
        EMPNO int(4) NOT NULL,
        ENAME varchar(10),
        JOB varchar(9),
        MGR int(4),
        HIREDATE date,
        SAL decimal(7,2),
        COMM decimal(7,2),
        DEPTNO int(2),
        CONSTRAINT PK_EMP PRIMARY KEY (EMPNO)
    );
    ALTER TABLE EMP ADD CONSTRAINT FK_DEPTNO FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO) ON UPDATE CASCADE ON DELETE RESTRICT;
    
    insert into dept(deptno, dname, loc) values(10,'ACCOUNTING','NEW YORK');
    insert into dept(deptno, dname, loc) values(20,'RESEARCH','DALLAS');
    insert into dept(deptno, dname, loc) values(30,'SALES','CHICAGO');
    insert into dept(deptno, dname, loc) values(40,'OPERATIONS','BOSTON');
    
    insert into emp values(7782,'CLARK','MANAGER',7839,'1981-06-09 00:00:00',2450,NULL,10);
    insert into emp values(7839,'KING','PRESIDENT',NULL,'1981-11-17 00:00:00',5000,NULL,10);
    insert into emp values(7934,'MILLER','CLERK',7782,'1982-01-23 00:00:00',1300,NULL,10);
    insert into emp values(7369,'SMITH','CLERK',7902,'1980-12-17 00:00:00',800,NULL,20);
    insert into emp values(7566,'JONES','MANAGER',7839,'1981-04-02 00:00:00',2975,NULL,20);
    insert into emp values(7788,'SCOTT','ANALYST',7566,'1987-07-13 00:00:00',3000,NULL,20);
    insert into emp values(7876,'ADAMS','CLERK',7788,'1987-07-13 00:00:00',1100,NULL,20);
    insert into emp values(7902,'FORD','ANALYST',7566,'1981-12-03 00:00:00',3000,NULL,20);
    insert into emp values(7499,'ALLEN','SALESMAN',7698,'1981-02-20 00:00:00',1600,300,30);
    insert into emp values(7521,'WARD','SALESMAN',7698,'1981-02-22 00:00:00',1250,500,30);
    insert into emp values(7654,'MARTIN','SALESMAN',7698,'1981-09-28 00:00:00',1250,1400,30);
    insert into emp values(7698,'BLAKE','MANAGER',7839,'1981-05-01 00:00:00',2850,NULL,30);
    insert into emp values(7844,'TURNER','SALESMAN',7698,'1981-09-08 00:00:00',1500,0,30);
    insert into emp values(7900,'JAMES','CLERK',7698,'1981-12-03 00:00:00',950,NULL,30);