MySQL Dump, Restore 관련 필요한 명령어

2025. 2. 26. 16:25Linux/MySQL

728x90
SMALL
  • 개요
MySQL을 운영할 때 필요한 작업중에는 MySQL dump 및 restore 작업이 있다. 이에 관련된 명령어를 정리해봤다.

 

  • 명령어
## mysql database create 확인
show create database <database>;

## mysql table create 확인
show create table <table>;

## mysql schema dump 명령어 예시
mysqldump -u <user> -h <mysql-host> -p \
  --no-data 
  --skip-comments \
  --skip-set-charset \
  --skip-add-drop-table \
  --skip-add-locks \
  --skip-disable-keys \
  --skip-triggers \
  --skip-routines \
  --set-gtid-purged=OFF \
  <database> > schema.sql

## mysql dump 명령어 예시
mysqldump -u <user> -h <mysql-host> -p --single-transaction --complete-insert --set-gtid-purged=OFF --no-create-info <database> \
table1 \
table2 \
table3 > mysqldump.sql

## mysql restore 명령어 예시
mysql -u <user> -h <mysql-host> -p <database> < mysqldump.sql
728x90
LIST

'Linux > MySQL' 카테고리의 다른 글

install MySQL client on amazon linux 2023  (0) 2023.06.21
install MySQL client version 8 on amazon linux 2  (0) 2022.08.25