Database
MySQL Dump& Import
Xuniverse
2017. 9. 18. 19:28
기본조건
host 192.168.4.233 (혹은 ServerAddress)
root id root
root ps rootps
mysql -h 192.168.4.233 -u root -p
mysql 명령어 사용시 호스트가 localhost일 경우 생략 가능하고 비밀번호가 없을 경우에도 생략 가능하다. -p 옵션이 붙어 있을 경우 명령어 입력시 비밀번호를 물어본다.
DUMP
Database 전체 덤프(target_databaseA, target_databaseB, target_databaseC 전체)
mysqldump -u root -p --all-databases > target_database_dump.sql
원격지(ex. Server)의 데이터베이스일 경우
mysqldump -h 192.168.4.233 -u root -p --all-databases > target_database_dump.sql
Database만 덤프
mysqldump -u root -p target_database > target_database_dump.sql
Table 구조 만 덤프
mysqldump -uroot -p --no-data target_database target_table > target_table_dump.sql
Table만 덤프
mysqldump -uroot -p target_database target_table > target_table_dump.sql
Table구조 제외한 테이블 데이터만 덤프
mysqldump -uroot -p --no-create target_database target_table > target_table_dump.sql
IMPORT
mysql -u root -p import_target_database < target_table_dump.sql
orig
mysqldump -uroot -ppass tdb> tdb.sql
-ppass 띄어쓰기 구분이 어떻게 되는지 모르겠음..
띄어쓰기해서 -p pass 이렇게 하면 pass를 dump대상 데이터베이스로 인식하던데..
기타)
데이터베이스 create
mysqladmin -u root -p create import_target_database
참고:
http://luckyyowu.tistory.com/184
http://itposting.tistory.com/18
http://dustjrdk.iptime.org/?p=329
https://www.lesstif.com/pages/viewpage.action?pageId=17105804