Skip to content

DB 백업 및 이전 복구 방법

Suwon Chae edited this page Mar 22, 2019 · 6 revisions

MariaDB를 사용하면 매우 간단하게 백업 및 이전, 복구가 가능합니다.

백업

mysqldump yona -uyona -p암호 > backup.sql

주의: Windows 의 경우, 그냥 콘솔에서 상기 커맨드를 실행하면 '권한없음' 에러가 발생합니다.

  • 시작 > 모든 프로그램 > MariaDB 10.x > Command Prompt 바로가기를 '관리자 권한으로 실행' 해서 콘솔창을 실행하세요.

복구

  • Yona 중지
  • admin 계정으로 로그인
mysql -uroot -p암호
  • drop database yona
drop database yona;
  • create database yona
create database yona
DEFAULT CHARACTER SET utf8mb4
DEFAULT COLLATE utf8mb4_bin;
  • grant
GRANT ALL ON yona.* to 'yona'@'localhost';
  • exit
  • mysql yona -uroot < backup.sql
  • Yona 재시작

로그 예)

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2755
Server version: 10.1.19-MariaDB Homebrew

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use yona
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [yona]> drop database yona
    -> ;
Query OK, 51 rows affected (0.19 sec)

MariaDB [(none)]> create database yona
    ->   DEFAULT CHARACTER SET utf8mb4
    ->   DEFAULT COLLATE utf8mb4_bin
    -> ;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL ON yona.* to 'yona'@'localhost';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> exit
Bye

mysql yona -uroot < backup.sql

참조: https://mariadb.com/kb/en/mariadb/backup-and-restore-overview/

Clone this wiki locally