MySQL db dump로 DB 내용을 백업 받은 것을 다시 MySQL에 복구하고자할 때 복구가 되지 않는 경우가 있다.
MySQL db에 접속할 계정의 user id가 root라고한다면 아래와 같은 커맨더가 정상적으로 DB를 복구해야 한다.
(test.sql이 DB 내용을 dump로 백업 받은 파일이고 복구하고자 하는 DB가 testDB라고 할 경우. 아래는 맥, 리눅스에서의 명령어 예이다)
 
$ mysql -uroot -p testDb < /Users/Documents/test.sql

testDb를 열어서 보면 Empty인 경우가 있다.
이렇게 복구가 안되면 다음을 체크해 볼것

아래의 내용은 커맨드 라인에서가 아닌 phpmyAdmin을 이용해서 복구를 할 경우에 대한 내용이다.
phpinfo()를 실행해서 나온 결과에서 

upload_max_filesize ==> 이 값이 아마도 기본 값 2M로 되어 있을 것이다.
post_max_size ==> 이 값이 아마도 기본 값 8M로 되어 있을 것이다.

이럴경우 test.sql의 크기가 upload_max_filesize에서 설정한 2Mb보다 클 경우 복구가 안될 것이다.
이 경우 php.ini 파일을 열어서 upload_max_filesize의 값을 더 높게 설정해 주어야 한다.

맥이나 리눅스의 경우 /etc/php.ini가 해당 파일의 경로이다.
참고적으로 post_max_size의 값이 upload_max_filesize의 설정 값보다 더 높게 설정해야 한다는 것이다.

자세한 정보는 아래를 참조

1.16 I cannot upload big dump files (memory, HTTP or timeout problems).

Starting with version 2.7.0, the import engine has been re–written and these problems should not occur. If possible, upgrade your phpMyAdmin to the latest version to take advantage of the new import features.

The first things to check (or ask your host provider to check) are the values of max_execution_time, upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these settings limit the maximum size of data that can be submitted and handled by PHP. Please note that post_max_size needs to be larger than upload_max_filesize. There exist several workarounds if your upload is too big or your hosting provider is unwilling to change the settings:

Look at the $cfg['UploadDir'] feature. This allows one to upload a file to the server via scp, FTP, or your favorite file transfer method. PhpMyAdmin is then able to import the files from the temporary directory. More information is available in the Configuration of this document.

Using a utility (such as BigDump) to split the files before uploading. We cannot support this or any third party applications, but are aware of users having success with it.

If you have shell (command line) access, use MySQL to import the files directly. You can do this by issuing the “source” command from within MySQL:

source filename.sql;

+ Recent posts