在这里,您可以找到一个全面的解决方案来转储 mysql 结构和数据,例如在 PMA 中(并且不使用 exec、passthru 等):
https://github.com/antarasi/MySQL-Dump-with-Foreign-keys
它是 dszymczuk 项目的分支,具有我的增强功能。
用法很简单
<?php
//MySQL connection parameters
$dbhost = 'localhost';
$dbuser = 'dbuser';
$dbpsw = 'pass';
$dbname = 'dbname';
//Connects to mysql server
$connessione = @mysql_connect($dbhost,$dbuser,$dbpsw);
//Set encoding
mysql_query("SET CHARSET utf8");
mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'");
//Includes class
require_once('FKMySQLDump.php');
//Creates a new instance of FKMySQLDump: it exports without compress and base-16 file
$dumper = new FKMySQLDump($dbname,'fk_dump.sql',false,false);
$params = array(
//'skip_structure' => TRUE,
//'skip_data' => TRUE,
);
//Make dump
$dumper->doFKDump($params);
?>
奇迹般有效 :-)