[mysql/mariaDB] dump export/import 하기

2021. 3. 9. 17:18IT개발/Database

반응형

1.  dump file export(내보내기)

 

mysqldump -u 계정 -p 내보낼_DB명 > 내보낼_dump파일의_경로_및_파일명

 

예시) mysqldump -u root -p egov3.7 > D:\DB\MariaDB\dump\egov3.7.sql

 

Enter password: ****

 

2.  dump file import(가져오기)

 

mysql -u 계정 -p 대상DB < 가져올_dump파일의_경로_및_파일명

 

예시) mysql -u root -p egov3.7 < D:\DB\MariaDB\dump\egov3.7.sql

 

Enter password: ****

 

 

============================================================================

 

 

===기타 참고할 명령어==

-- user 생성
create user 'project1'@'%' identified by '@project11029384756';
create user 'project2'@'%' identified by '@project21029384756';

-- user 삭제
drop user 'project1'@'%';
drop user 'project2'@'%';

-- user 권한부여
grant all privileges on project1.* to 'project1'@'%';
grant all privileges on project2.* to 'project2'@'%';

-- dump 파일 만들기(export)
mysqldump -u root -p project1 > D:\DB\MariaDB\dump\project5_2020_02_21.sql
mysqldump -u root -p project2 > D:\DB\MariaDB\dump\project4_2020_02_21.sql

-- dump 파일 읽어오기(import)
mysql -u root -p project1 < D:\DB\MariaDB\dump\project5_2020_01.sql
mysql -u root -p project2 < D:\DB\MariaDB\dump\project4_2020_01.sql

============================================================================

 

참끝!

반응형