본문 바로가기
IT/Linux

[Linux/MariaDB] mysqldump로 데이터베이스 백업, 복사하기

by 저당단 2023. 10. 12.

※ mariadb의 워크벤치가 아닌 cmd에서 실행해야 합니다.

※ definer로 설정된 계정에 grant all privileges on *.* to '계정이름'@'%' identified by '비밀번호'; 로 모든 권한 부여하기

 

특정 DB의 모든 요소(데이터 포함)를 파일로 저장

mysqldump -u root -p DB이름 > 덤프파일이름.sql

 

특정 DB의 프로시저만 파일로 저장

mysqldump -u root -p --routines --no-create-info --no-data --no-create-db --skip-opt DB이름 > 덤프파일이름.sql

 

저장된 파일을 백업

mysql -u root -p 저장할DB명 < 덤프파일이름.sql