如何在不使用dbutil的情况下导入使用Codeigniter导出的SQL转储文件

问题描述

我使用带有dbigns和codeigniter的sql db导出了数据文件。

$this->load->dbutil();
$this->load->helper('file');
$this->load->helper('download');

$dumpOption = [
  'tables'        => [],// Array of tables to backup.
  'ignore'        => [],// List of tables to omit from the backup
  'format'        => 'txt',// gzip,zip,txt
  'filename'      => 'mybackup.sql',// File name - NEEDED ONLY WITH ZIP FILES
  'add_drop'      => true,// Whether to add DROP TABLE statements to backup file
  'add_insert'    => true,// Whether to add INSERT data to backup file
  'newline'       => "\n",// Newline character used in backup file
  'foreign_key_checks' => false,];

if (ENVIRONMENT !== 'production') {
  if ($this->dbutil->database_exists('db')) {
     $backup = $this->dbutil->backup($dumpOption);
        try {
          echo "loading database ..... \n";
          write_file('./db/dump/mybackup.sql',$backup,'w+');
          echo "preparing media data.... \n";
        } catch (Exception $e) {
          printf('Message: ' . $e->getMessage());
        }
      } else {
        echo 'database squirrel does not exist.';
      }
    }
}

但是当我使用phpadmin导入此文件时,却返回了这种问题。

Running: mysql.exe --defaults-file="\appdata\local\temp\tmpp5yat3.cnf"  --protocol=tcp --host=127.0.0.1 --user=root --port=3306 --default-character-set=utf8 --comments --database=squirrel  < "\\backend\\db\\dump\\mybackup.sql"
ERROR 1050 (42S01) at line 304: Table 'pin_post' already exists

Operation failed with exitcode 1
23:32:49 Import of \backend\db\dump\mybackup.sql has finished with 1 errors

这是发行行。

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `pin_post` AS select `pin`.`pin_id` AS `pin_id`,`pin`.`mem_id` AS `mem_id`,`pin`.`cmnt_id` AS `cmnt_id`,`pin`.`date` AS `date` from `pin`;

utf8_general_ci; <<<< this issue line.

如何解决此问题。 期待听到好消息。 谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)