24h購物| | PChome| 登入
2010-01-11 03:40:12| 人氣3,963| 回應0 | 上一篇 | 下一篇

MySQL 從 Web 匯入大量資料的 BigDump 工作

推薦 0 收藏 0 轉貼0 訂閱站台

        在進行 MySQL 管理的工具中 , 最常使用的就是 phpMyAdmin 這套工具了 , 但在今天想試著不要再用指令去操作 MySQL dump 下來的資料移轉時 , 發現了在 phpMyAdmin 中匯入資料是有容量上的限制的。


(  phpMyAdmin 的 2048 KB 限制)

       在發生問題的過程中  , 由 phpMyAdmin 出現的警告圖(如下) , 找到了解決的方法建議。


      文件的捷徑就指向了 Documentation.html#faq1_16 中提到

(以下轉載自 phpMyAdmin 中的 Documentation.html#faq1_16 中的內容)

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 upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these three settings limit the maximum size of data that can be submitted and handled by PHP. One user also said that post_max_size and memory_limit need 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 section 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.

        在這一個 Topic 中就指出了設定的調整方法或使用 BigDump 這一個工具來做輔助 , 但想說還要去裝一個工具 , 本來覺得麻煩 , 但還是看一下 BigDump 中的說明 , 突然發現這是一個很有趣的工具 . 由  http://www.ozerov.de/bigdump.php 前往 BigDump 的網站 , 開宗明義就說明了 , 它是 Staggered import of large and very large MySQL Dumps (like phpMyAdmin 2.x Dumps) even through the web servers with hard runtime limit and those in safe mode. , 其實有大吃一驚 , 在 Internet 上果然什麼都有 , 並且還有人寫出這轉「專用」於轉檔的工具....真是令人嘆為觀止呀!


          並且就先來看一下它的設定和功能說明吧!

          首先先說明一下版本 , 在今天看到在  http://www.ozerov.de/bigdump.php  可以下載的版本是 BigDump ver. 0.31b (beta) (10 KB ZIP archive)  這一個版本和下載 ZIP 檔。並且在網站上就說明了 Version 0.31b includes some very important bugfixes and other improvements. (這個版本修正了許多重大的問題 及提供許多改進) , 但句後也提到了 Please don't hesitate to report any bugs in this release  (如果在這個版本中發現問題 , 也請不要猶豫的反應給它們) , 並且在下方就說明了需要準備的事項。



 以上的準備事項要注意的,就是要傳 gzip 壓縮過的檔額,就只有限於在 PHP 4.3.0 以後的版本才可以 , 這是要注意的 。


   從 http://www.ozerov.de/bigdump.php 下載 bigdump.zip 這一個檔案。



      把 bigdump.zip 解壓縮開來 , 可以看到 bigdump.php 這一個檔案 , 使用文字編輯器打開它, 我們需要進行一點編輯。


      在  bigdump.php  中 , 編輯連線到 MySQL 的連線參數 , 把 資訊設定好!

      db_server 就是要連線到 MySQL Server 的 IP 或 機器名稱   

      $db_name 是要匯入資料的 database 名稱

      $db_username 和 $ db_password 就是 連線到 database 的帳號和密碼


     接下來就是要設定要匯入的檔案名稱 , 由 $filename 就是設定好要匯入執行的 sql 檔案

    而 $linespersession 和 $delaypersession 是為了避免 MySQL 太忙的設定!

    再接下來就是設定跟資料庫連線的 編碼 由 $db_connection_charset 的編碼設定


設定好以上的設定,就可以把 bigdump.php 放在 apache - php 的執行環境中了

正確的設定就會看到上面的畫面



    如果沒有設定 $filename (就是要處理的檔案) 就會看到上面的 web page!!!

 

台長: 克理斯 在 Internet!
人氣(3,963) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 數位資訊(科技、網路、通訊、家電)

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文