dqyym3667 2010-06-05 13:12
浏览 99

php导入larg表到phpmyadmin数据库

I dropped one of the tables from the database accidentally. fortunately, I have back-up. (I have used the "Auto backup for mysql")

The back-up of the table is stored as .txt file (56 Megabytes) on my PC.

I tried to import it by PhpMyAdmin and the import failed because the file is too large to import.

then I uploaded the file to /home/tablebk directory. I have some experiences in php. I know that I would import it with this code, but i don't know the sql statment for this import.

what is have to put as $line variable?

please help me :( :(

<?php

    $dbhost = 'localhost';          
$dbuser = 'mysite';         
$dbpw = 'password';         
$dbname = 'databasename';

$file = @fopen('country.txt', 'r');

if ($file)
{
    while (!feof($file))
    {
        $line = trim(fgets($file));
        $flag = mysql_query($line);

        if (isset($flag))
        {
            echo 'Insert Successfully<br />';
        }

        else
        {
            echo mysql_error() . '<br/>';
        }

        flush();
    }

    fclose($file);
}

echo '<br />End of File';

?>
  • 写回答

2条回答 默认 最新

  • doudeng9425 2010-06-05 13:14
    关注

    Try BigDump, which solves the problem elegantly and reliably. It basically does what you want, but with more safety mechanisms and several ways to restart in the middle of the file. Also, it has beautiful progress indicators, and... oh, it's already written, so you don't need to write your own script. No need to reinvent the wheel. (I'm not affiliated with BigDump or its developer(s) in any way.)

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮