I.lib()/I.lib(Mysql)

MySQL 데이터베이스 (Database) Export/Import

.07274. 2013. 11. 8. 11:25



MySQL 데이터베이스를 백업하거나 혹은 다른 머신 (Machine)으로 옮겨야 한다면,

다음과 같이 export할 수 있다.

mysqldump -uusername -ppassword database_name > dump.sql

테이블 (Table) 스키마 (Schema)와 데이터는 export되지만

import를 위해 계정과 데이터베이스는 다음과 같이 생성한다.

grant all privileges on database_name.* to 'username'@'localhost' identified by 'password';

create database database_name;

다음과 같이 import할 수 있다.

mysql -uusername -ppassword database_name < dump.sql

import가 완료되었음을 확인할 수 있다.