<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=PHP_-_Datenbank_exportieren</id>
	<title>PHP - Datenbank exportieren - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=PHP_-_Datenbank_exportieren"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=PHP_-_Datenbank_exportieren&amp;action=history"/>
	<updated>2026-05-09T09:55:56Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=PHP_-_Datenbank_exportieren&amp;diff=24109&amp;oldid=prev</id>
		<title>37.49.72.8 am 4. November 2019 um 16:58 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=PHP_-_Datenbank_exportieren&amp;diff=24109&amp;oldid=prev"/>
		<updated>2019-11-04T16:58:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 4. November 2019, 16:58 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  https://stackoverflow.com/questions/10020022/how-to-export-and-import-mysql-database-with-its-data-using-php-script?noredirect=1&amp;amp;lq=1&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  https://stackoverflow.com/questions/10020022/how-to-export-and-import-mysql-database-with-its-data-using-php-script?noredirect=1&amp;amp;lq=1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Ohne exec()&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;== &lt;/ins&gt;Ohne exec() &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l106&quot; &gt;Zeile 106:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 106:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Mit Exec&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;== &lt;/ins&gt;Mit Exec &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$tableName  = &amp;#039;mypet&amp;#039;;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$tableName  = &amp;#039;mypet&amp;#039;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>37.49.72.8</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=PHP_-_Datenbank_exportieren&amp;diff=24108&amp;oldid=prev</id>
		<title>37.49.72.8: Die Seite wurde neu angelegt: „ https://stackoverflow.com/questions/10020022/how-to-export-and-import-mysql-database-with-its-data-using-php-script?noredirect=1&amp;lq=1  Ohne exec() &lt;syntaxhigh…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=PHP_-_Datenbank_exportieren&amp;diff=24108&amp;oldid=prev"/>
		<updated>2019-11-04T16:58:10Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „ https://stackoverflow.com/questions/10020022/how-to-export-and-import-mysql-database-with-its-data-using-php-script?noredirect=1&amp;amp;lq=1  Ohne exec() &amp;lt;syntaxhigh…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt; https://stackoverflow.com/questions/10020022/how-to-export-and-import-mysql-database-with-its-data-using-php-script?noredirect=1&amp;amp;lq=1&lt;br /&gt;
&lt;br /&gt;
Ohne exec()&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/*&lt;br /&gt;
##### EXAMPLE #####&lt;br /&gt;
   EXPORT_DATABASE(&amp;quot;localhost&amp;quot;,&amp;quot;user&amp;quot;,&amp;quot;pass&amp;quot;,&amp;quot;db_name&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
##### Notes #####&lt;br /&gt;
     * (optional) 5th parameter: to backup specific tables only,like: array(&amp;quot;mytable1&amp;quot;,&amp;quot;mytable2&amp;quot;,...)&lt;br /&gt;
     * (optional) 6th parameter: backup filename (otherwise, it creates random name)&lt;br /&gt;
     * IMPORTANT NOTE ! Many people replaces strings in SQL file, which is not recommended. READ THIS:  http://itask.software/tools/wordpress-migrator&lt;br /&gt;
     * If you need, you can check &amp;quot;import.php&amp;quot; too&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
// by https://github.com/tazotodua/useful-php-scripts //&lt;br /&gt;
function EXPORT_DATABASE($host,$user,$pass,$name,$tables=false, $backup_name=false)&lt;br /&gt;
{&lt;br /&gt;
	set_time_limit(3000);&lt;br /&gt;
	$mysqli = new mysqli($host,$user,$pass,$name);&lt;br /&gt;
	$mysqli-&amp;gt;select_db($name); $mysqli-&amp;gt;query(&amp;quot;SET NAMES &amp;#039;utf8&amp;#039;&amp;quot;);&lt;br /&gt;
	$queryTables = $mysqli-&amp;gt;query(&amp;#039;SHOW TABLES&amp;#039;); while($row = $queryTables-&amp;gt;fetch_row()) {&lt;br /&gt;
		$target_tables[] = $row[0];&lt;br /&gt;
	}&lt;br /&gt;
	if($tables !== false) {&lt;br /&gt;
		$target_tables = array_intersect( $target_tables, $tables);&lt;br /&gt;
	}&lt;br /&gt;
	$content = &amp;quot;SET SQL_MODE = \&amp;quot;NO_AUTO_VALUE_ON_ZERO\&amp;quot;;\r\nSET time_zone = \&amp;quot;+00:00\&amp;quot;;\r\n\r\n\r\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\r\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\r\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\r\n/*!40101 SET NAMES utf8 */;\r\n--\r\n-- Database: `&amp;quot;.$name.&amp;quot;`\r\n--\r\n\r\n\r\n&amp;quot;;&lt;br /&gt;
	foreach($target_tables as $table){&lt;br /&gt;
		if (empty($table)){&lt;br /&gt;
			continue;&lt;br /&gt;
		}&lt;br /&gt;
		$result	= $mysqli-&amp;gt;query(&amp;#039;SELECT * FROM `&amp;#039;.$table.&amp;#039;`&amp;#039;);&lt;br /&gt;
		$fields_amount=$result-&amp;gt;field_count;&lt;br /&gt;
		$rows_num=$mysqli-&amp;gt;affected_rows;&lt;br /&gt;
		$res = $mysqli-&amp;gt;query(&amp;#039;SHOW CREATE TABLE &amp;#039;.$table);&lt;br /&gt;
		$TableMLine=$res-&amp;gt;fetch_row();&lt;br /&gt;
		$content .= &amp;quot;\n\n&amp;quot;.$TableMLine[1].&amp;quot;;\n\n&amp;quot;;&lt;br /&gt;
		$TableMLine[1]=str_ireplace(&amp;#039;CREATE TABLE `&amp;#039;,&amp;#039;CREATE TABLE IF NOT EXISTS `&amp;#039;,$TableMLine[1]);&lt;br /&gt;
		for ($i = 0, $st_counter = 0; $i &amp;lt; $fields_amount;   $i++, $st_counter=0) {&lt;br /&gt;
			while($row = $result-&amp;gt;fetch_row())	{ //when started (and every after 100 command cycle):&lt;br /&gt;
				if ($st_counter%100 == 0 || $st_counter == 0 )	{&lt;br /&gt;
					$content .= &amp;quot;\nINSERT INTO &amp;quot;.$table.&amp;quot; VALUES&amp;quot;;&lt;br /&gt;
				}&lt;br /&gt;
				$content .= &amp;quot;\n(&amp;quot;;    for($j=0; $j&amp;lt;$fields_amount; $j++){ $row[$j] = str_replace(&amp;quot;\n&amp;quot;,&amp;quot;\\n&amp;quot;, addslashes($row[$j]) );&lt;br /&gt;
					if (isset($row[$j])){&lt;br /&gt;
						$content .= &amp;#039;&amp;quot;&amp;#039;.$row[$j].&amp;#039;&amp;quot;&amp;#039; ;&lt;br /&gt;
					} else{&lt;br /&gt;
						$content .= &amp;#039;&amp;quot;&amp;quot;&amp;#039;;&lt;br /&gt;
					}&lt;br /&gt;
					if ($j&amp;lt;($fields_amount-1)){&lt;br /&gt;
						$content.= &amp;#039;,&amp;#039;;&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
				$content .=&amp;quot;)&amp;quot;;&lt;br /&gt;
				//every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler&lt;br /&gt;
				if ( (($st_counter+1)%100==0 &amp;amp;&amp;amp; $st_counter!=0) || $st_counter+1==$rows_num) {$content .= &amp;quot;;&amp;quot;;} else {$content .= &amp;quot;,&amp;quot;;}	$st_counter=$st_counter+1;&lt;br /&gt;
			}&lt;br /&gt;
		} $content .=&amp;quot;\n\n\n&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	$content .= &amp;quot;\r\n\r\n/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\r\n/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\r\n/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;&amp;quot;;&lt;br /&gt;
	$backup_name = $backup_name ? $backup_name : $name.&amp;#039;___(&amp;#039;.date(&amp;#039;H-i-s&amp;#039;).&amp;#039;_&amp;#039;.date(&amp;#039;d-m-Y&amp;#039;).&amp;#039;).sql&amp;#039;;&lt;br /&gt;
	ob_get_clean(); header(&amp;#039;Content-Type: application/octet-stream&amp;#039;);  header(&amp;quot;Content-Transfer-Encoding: Binary&amp;quot;);  header(&amp;#039;Content-Length: &amp;#039;. (function_exists(&amp;#039;mb_strlen&amp;#039;) ? mb_strlen($content, &amp;#039;8bit&amp;#039;): strlen($content)) );    header(&amp;quot;Content-disposition: attachment; filename=\&amp;quot;&amp;quot;.$backup_name.&amp;quot;\&amp;quot;&amp;quot;);&lt;br /&gt;
	echo $content; exit;&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Import:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// EXAMPLE:	IMPORT_TABLES(&amp;quot;localhost&amp;quot;,&amp;quot;user&amp;quot;,&amp;quot;pass&amp;quot;,&amp;quot;db_name&amp;quot;, &amp;quot;my_baseeee.sql&amp;quot;); //TABLES WILL BE OVERWRITTEN&lt;br /&gt;
// P.S. IMPORTANT NOTE for people who try to change/replace some strings  in SQL FILE before importing, MUST READ:  https://goo.gl/2fZDQL&lt;br /&gt;
&lt;br /&gt;
// https://github.com/tazotodua/useful-php-scripts&lt;br /&gt;
function IMPORT_TABLES($host,$user,$pass,$dbname, $sql_file_OR_content){&lt;br /&gt;
	set_time_limit(3000);&lt;br /&gt;
	$SQL_CONTENT = (strlen($sql_file_OR_content) &amp;gt; 300 ?  $sql_file_OR_content : file_get_contents($sql_file_OR_content)  );&lt;br /&gt;
	$allLines = explode(&amp;quot;\n&amp;quot;,$SQL_CONTENT);&lt;br /&gt;
	$mysqli = new mysqli($host, $user, $pass, $dbname);&lt;br /&gt;
	if (mysqli_connect_errno()){&lt;br /&gt;
		echo &amp;quot;Failed to connect to MySQL: &amp;quot; . mysqli_connect_error();&lt;br /&gt;
	}&lt;br /&gt;
	$zzzzzz = $mysqli-&amp;gt;query(&amp;#039;SET foreign_key_checks = 0&amp;#039;);&lt;br /&gt;
	preg_match_all(&amp;quot;/\nCREATE TABLE(.*?)\`(.*?)\`/si&amp;quot;, &amp;quot;\n&amp;quot;. $SQL_CONTENT, $target_tables);&lt;br /&gt;
	foreach ($target_tables[2] as $table){&lt;br /&gt;
		$mysqli-&amp;gt;query(&amp;#039;DROP TABLE IF EXISTS &amp;#039;.$table);&lt;br /&gt;
	}&lt;br /&gt;
	$zzzzzz = $mysqli-&amp;gt;query(&amp;#039;SET foreign_key_checks = 1&amp;#039;);&lt;br /&gt;
	$mysqli-&amp;gt;query(&amp;quot;SET NAMES &amp;#039;utf8&amp;#039;&amp;quot;);&lt;br /&gt;
	$templine = &amp;#039;&amp;#039;;	// Temporary variable, used to store current query&lt;br /&gt;
	foreach ($allLines as $line)	{											// Loop through each line&lt;br /&gt;
		if (substr($line, 0, 2) != &amp;#039;--&amp;#039; &amp;amp;&amp;amp; $line != &amp;#039;&amp;#039;) {$templine .= $line; 	// (if it is not a comment..) Add this line to the current segment&lt;br /&gt;
			if (substr(trim($line), -1, 1) == &amp;#039;;&amp;#039;) {		// If it has a semicolon at the end, it&amp;#039;s the end of the query&lt;br /&gt;
				if(!$mysqli-&amp;gt;query($templine)){&lt;br /&gt;
					print(&amp;#039;Error performing query \&amp;#039;&amp;lt;strong&amp;gt;&amp;#039; . $templine . &amp;#039;\&amp;#039;: &amp;#039; . $mysqli-&amp;gt;error . &amp;#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;#039;);&lt;br /&gt;
				}&lt;br /&gt;
				$templine = &amp;#039;&amp;#039;; // set variable to empty, to start picking up the lines after &amp;quot;;&amp;quot;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}	return &amp;#039;Importing finished. Now, Delete the import file.&amp;#039;;&lt;br /&gt;
}   //see also export.php&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Mit Exec&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$tableName  = &amp;#039;mypet&amp;#039;;&lt;br /&gt;
$backupFile = &amp;#039;backup/mypet.sql&amp;#039;;&lt;br /&gt;
$query      = &amp;quot;SELECT * INTO OUTFILE &amp;#039;$backupFile&amp;#039; FROM $tableName&amp;quot;;&lt;br /&gt;
$result = mysql_query($query);&lt;br /&gt;
//or&lt;br /&gt;
&lt;br /&gt;
$backupFile = $dbname . date(&amp;quot;Y-m-d-H-i-s&amp;quot;) . &amp;#039;.gz&amp;#039;;&lt;br /&gt;
$command = &amp;quot;mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip &amp;gt;     $backupFile&amp;quot;;&lt;br /&gt;
system($command);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>37.49.72.8</name></author>
	</entry>
</feed>