Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- postgresql
- opensource
- maxclients
- autovacuum
- DELETE
- Cloud DB for MySQL
- vacuum
- mongo
- InnoDB
- cdb
- ncloud
- mysql
- RDBMS
- NCP
- MyISAM
- zabbix
- REDIS
- RDS
- slack
- percona
- 성능테스트
- Maria
- OD
- jmeter
- Connection
- 6.2.7
- online ddl
- DML
- Docker
- NOSQL
Archives
- Today
- Total
개인 공부
MySQL 백업 & 복구 ( mysqldump ) 본문
반응형
오늘은 Mysql 를 백업 복구할때 사용하는 mysqldump에 관련해서 써 볼 생각이다.
- mysqldump 클라이언트 유틸리티는 논리적 백업을 수행하여 기존 DB 개체 정의 및 테이블 데이터를 복제하기 위해 실행하기 위해 실행할 수 있는 SQL문을 생성합니다. 백업 또는 다른 SQL 서버로 전송하기 위해 하나 이상의 MySQL DB를 덤프 합니다. mysqldump 명령은 CSV, XML 등으로 생성할 수도 있습니다.
[장점]
1. dump 파일을 보고 직접 SQL 구문을 확인 & 수정할 수 있다.
2. mysqldump는 많은 옵션을 가지고 있어 잘 활용한다면 좋은 유틸리티이다.
[단점]
1.다른 백업 유틸리티에 비해 속도가 느리다.
2.Dump 중 에러가 발생한다면 처음부터 다시 시도해야 된다.
Database 상태
DBName : employees Table : current_dept_emp / departments / dept_emp / dept_emp_latest_date / dept_manager / employees / salaries / titles |
MySQL DB Backup
#mysqldump -u [사용자 계정] -p[패스워드] --routines --triggers --single-transaction [Database 명] > 백업.sql #Option --routines = procedure/function 같이 Export --triggers = trigger 같이 Export --single-transaction = dump를 하나의 트랜잭션으로 실행함으로 InnoDB 스토리지 엔진을 사용하는 테이블에 대해서 Lock없이 일관된 덤프를 받을수 있다 #[root:LEE:/tmp/test_db > mysqldump -uroot -proot --routines --triggers --single-transaction employees > employees.sql |
MySQL DB Restore
#mysql -u[사용자계정] -p[패스워드] [복원할 Database 명] < 백업.sql #[root:LEE:/tmp/test_db > mysql -uroot -proot employees < employees.sql |
MySQL Table Backup
#mysqldump -u [사용자 계정] -p[패스워드] --routines --triggers --single-transaction [Database 명] [Table명 ] > 백업.sql #[root:LEE:/tmp/test_db > mysqldump -uroot -proot --routines --triggers --single-transaction employees departments > employees.department.sql |
MySQL Table Restore
#mysql -u[사용자계정] -p[패스워드] [복원할 Database 명] < 백업.sql #[root:LEE:/tmp/test_db > mysql -uroot -proot employees < employees.department.sql |
반응형
'MySQL & Maria' 카테고리의 다른 글
[MARIA] Maxscale Replication (0) | 2021.09.15 |
---|---|
[MySQL] Connection 파라미터 설정 (0) | 2021.09.08 |
[MySQL] MySQL User 생성 & 권한 부여 (0) | 2021.08.25 |
Slow Query 분석 Website (0) | 2021.08.24 |
[MySQL] RENAME DATABASE (0) | 2021.08.10 |