IT TIP

phpmyadmin에서 대용량 SQL 파일을 가져 오는 방법

itqueen 2020. 10. 27. 23:54
반응형

phpmyadmin에서 대용량 SQL 파일을 가져 오는 방법


약 12MB의 SQL 파일을 가져오고 싶습니다. 그러나로드하는 동안 문제가 발생합니다. SQL 파일을 분할하지 않고 업로드하는 방법이 있습니까?


OS의 취향에 따라 mysql 콘솔에서 가져 오십시오.

mysql -u {DB-USER-NAME} -p {DB-NAME} < {db.file.sql path}

또는 원격 서버에있는 경우 -h 플래그를 사용하여 호스트를 지정합니다.

mysql -u {DB-USER-NAME} -h {MySQL-SERVER-HOST-NAME} -p {DB-NAME} < {db.file.sql path}

해야 할 3 가지 :

php.ini당신의 PHP 설치 (참고 : 조작 할 수있는 권리 php.ini 파일을 찾아, 당신은 CLI, 아파치, 또는 nginx를 위해 그것을 원하는 경우에 따라)

post_max_size=500M

upload_max_filesize=500M

memory_limit=900M

또는 다른 값을 설정하십시오.

apache가 설치되어있는 경우 apache를 다시 시작 / 다시로드 하고 nginx를 사용하는 경우 nginx의 경우 php-fpm을 다시로드 합니다.

원격 서버?

max_execution_time파일을 업로드하는 데 시간이 걸리므로 증가 합니다.

NGINX 설치?

: 당신은 추가해야합니다 client_max_body_size 912M;/etc/nginx/nginx.conf받는 http{...}블록


phpmyadmin 디렉토리에있는 config.inc.php 파일을 편집하십시오. 제 경우에는에 있습니다 C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php.

$cfg['UploadDir']그것에 있는 줄을 찾아서 업데이트하십시오.$cfg['UploadDir'] = 'upload';

그런 다음 phpmyadmin 디렉토리 (저는) 내에 'upload'라는 디렉토리를 만듭니다 C:\wamp\apps\phpmyadmin3.2.0.1\upload\.

그런 다음 가져 오려는 큰 SQL 파일을 새 upload디렉토리로 배치하십시오. 이제 phpmyadmin 콘솔의 db 가져 오기 페이지로 이동하면 이전에는 없었던 드롭 다운이 표시됩니다. 여기에는 방금 만든 업로드 디렉토리에있는 모든 SQL 파일이 포함되어 있습니다. 이제 이것을 선택하고 가져 오기를 시작할 수 있습니다.

Windows에서 WAMP를 사용하지 않는 경우 큰 문제없이이를 사용자 환경에 적용 할 수 있습니다.

참조 : http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/comment-page-4/


LINUX 사용자를위한 솔루션 (sudo로 실행)

'업로드'및 '저장'디렉토리를 만듭니다.

mkdir /etc/phpmyadmin/upload
mkdir /etc/phpmyadmin/save
chmod a+w /etc/phpmyadmin/upload
chmod a+w /etc/phpmyadmin/save

그런 다음 phpmyadmin의 구성 파일을 편집하십시오.

gedit /etc/phpmyadmin/config.inc.php

마지막으로 'upload'및 'save'디렉토리에 대한 절대 경로를 추가합니다.

$cfg['UploadDir'] = '/etc/phpmyadmin/upload';
$cfg['SaveDir'] = '/etc/phpmyadmin/save';

이제 /etc/phpmyadmin/upload폴더에 파일을 드롭 하면 phpmyadmin에서 파일 을 선택할 수 있습니다.

여기에 이미지 설명 입력

이 도움을 바랍니다.


한 줄이면 완료됩니다 (mysql 명령이 전역으로 사용 가능한지 확인하거나 mysql 설치 폴더로 이동하여 bin 폴더에 입력하십시오)

mysql -u database_user_name -p -D database_name < complete_file_path_with_file_name_and_extension 

여기

  • u 사용자를 의미
  • p 암호를 의미합니다.
  • D 데이터베이스를 의미

--- <데이터베이스 이름 뒤에 서명을 추가하는 것을 잊지 마십시오 ---

이름과 확장자가있는 완전한 파일 경로는 다음과 같을 수 있습니다.

c:\folder_name\"folder name"\sql_file.sql

--- 폴더와 파일 이름에 이중 따옴표를 사용하여 바인딩보다 공간이 포함 된 경우 ---

팁 및 참고 : 암호는 나중에 쓸 수 -p있지만 그 시간에 화면을보고있는 다른 사람에게 표시되므로 권장하지 않습니다. 입력하지 않으면 Enter 키를 눌러 명령을 실행할시기를 묻습니다.


.sql파일에 다음 구성을 사용하여 파일 을 가져올 수있었습니다 httpd.conf.

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
    AllowOverride AuthConfig
    Require all granted

    php_admin_value upload_max_filesize 128M
    php_admin_value post_max_size 128M
    php_admin_value max_execution_time 360
    php_admin_value max_input_time 360
</Directory>

zip 또는 tar 파일을 만들고 phpmyadmin에 업로드하십시오.


php.ini 파일을 편집해야합니다. upload_max_filesize post_max_size파일 크기에 맞게 다음 변경하십시오 .

phpinfo()현재 값을 확인하기 위해 실행 중 입니다. php.ini 파일을 직접 변경할 자유가 없다면 ini_set ()을 시도하십시오.

If that is also not an option, you might like to give bigdump a try.


For that you will have to edit php.ini file, If you are using the ubuntu server this is link Upload large file in phpMyAdmin might help you.


I dont understand why nobody mention the easiest way....just split the large file with http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/ and after just execute vie mySQL admin the seperated generated files starting from the one with Structure


Ok you use PHPMyAdmin but sometimes the best way is through terminal:

  • Connect to database: mysql -h localhost -u root -p (switch root and localhost for user and database location)
  • Start import from dump: \. /path/to/your/file.sql
  • Go take a coffe and brag about yourself because you use terminal.

And that's it. Just remember if you are in a remote server, you must upload the .sql file to some folder.


Change your server settings to allow file uploads larger than 12 mb and you should be fine. Usually the server settings are set to 5 to 8 mb for file uploads.


I stumbled on an article and this worked best for me

  1. Open up the config.inc.php file within the phpmyadmin dir with your favorite code editor. In your local MAMP environment, it should be located here:

Hard Drive » Applications » MAMP » bin » config.inc.php

  1. Do a search for the phrase $cfg[‘UploadDir’] – it’s going to look like this:

$cfg['UploadDir'] = '';

  1. Change it to look like this:

$cfg['UploadDir'] = 'upload';

  1. Then, within that phpmyadmin dir, create a new folder & name it upload.

  2. Take that large .sql file that you’re trying to import, and put it in that new upload folder.

  3. Now, the next time you go to import a database into phpMyAdmin, you’ll see a new dropdown field right below the standard browse area in your “File to Import” section.


Best way to upload a large file not use phpmyadmin . cause phpmyadin at first upload the file using php upload class then execute sql that cause most of the time its time out happened.

best way is : enter wamp folder>bin>mysql>bin dirrectory then write this line

mysql -u root -p listnames < latestdb.sql here listnames is the database name at first please create the empty database and the latestdb.sql is your sql file name where your data present .

but one important thing is if your database file has unicode data . you must need to open your latestdb.sql file and one line before any line . the line is :

SET NAMES utf8; then your command mode run this script code


  1. Open your sql file in a text editor (like Notepad)
  2. Select All -> Copy
  3. Go to phpMyAdmin, select your database and go to SQL tab
  4. Paste the content you have copied in clipboard
  5. It might popup a javascript error, ignore it
  6. Execute

the answer for those with shared hosting. Best to use this little script which I just used to import a 300mb DB file to my server. The script is called Big Dump.

provides a script to import large DB's on resource-limited servers


In MAMP, You could load huge files by :

  1. creating a new folder in this directory /MAMP/bin/phpMyAdmin/"folderName"

  2. and then edit "/MAMP/bin/phpMyAdmin/config.inc.php" line 531 :

       $cfg['UploadDir']= 'folderName';   
    
  3. Copy your .sql or .csv Files into this folder.

  4. 이제 "PhpMyAdmin"에 다른 옵션이 있습니다. 웹 서버 업로드 디렉토리에서 선택 newFolder / : 파일을 선택하고 가져올 수 있습니다.

    이제 모든 파일을로드 할 수 있습니다!


한 가지 해결책은 명령 줄을 사용하는 것입니다.

mysql -h yourhostname -u username -p databasename < yoursqlfile.sql

가져올 SQL 파일 의 경로 가 명시 적으로 지정되어 있는지 확인하십시오 .

제 경우에는 이것을 사용했습니다.

mysql -h localhost -u root -p databasename < /home/ejalee/dumps/mysqlfile.sql

짜잔! 당신은 갈 수 있습니다.

참고 URL : https://stackoverflow.com/questions/11305516/how-to-import-large-sql-file-in-phpmyadmin

반응형