Antworten auf Ihre häufigsten Fragen

Wie importiere und exportiere ich große Datenbanken?

English version below

Normalerweise können Sie Ihre Datenbanken bequem über phpMyAdmin oder eigene Skripte verwalten. Bei großen Datenmengen schlägt das allerdings fehl, da die maximale Ausführungszeit eines PHP-Skriptes serverseitig begrenzt ist (das Export-Script wird abgebrochen) und der Upload von Datenbank-Dumps über 256 MB nicht möglich ist. Hier finden Sie Methoden, wie Sie Ihre Daten dennoch importieren können:

Mit MyOOSDumper

Mit dem Programm "MyOOSDumper" ist es möglich, über eine Weboberfläche Sicherungen Ihrer Datenbanken zu erzeugen. Diese Anwendung ist allerdings nicht vorinstalliert und muss zunächst in Ihren Webspace kopiert und einige Rechte gesetzt werden. Dies ist in der mitgelieferten Anleitung beschrieben.

Per PHP-Skript (manuell)

Bitte importieren Sie nur Daten mit diesen Skripten, die ebenso erstellt wurden. Haben Sie den Dump z.B. mit phpMyAdmin erzeugt, kann es zu Problemen kommen.

Erstellen Sie je nach Bedarf eine Textdatei mit dem angegebenen Namen und Inhalt. Beachten Sie dabei folgende Hinweise:

  • Das Unterverzeichnis in das der Dump gespeichert werden soll muss dem wp1234567-Benutzer gehören.
    • Datenbankserver durch den Namen Ihres DB-Servers, also normalerweise "localhost".
    • Username durch den Namen Ihres MySQL-Benutzers ("dbu"+Paketnummer, z.B. "dbu1234567").
    • Passwort durch dessen von Ihnen gewähltes Passwort.
    • Datenbankname durch den Namen Ihrer Datenbank (z.B. "db1234567-meinedb").
    • Pfad zu Ihrem Produkt durch den im KIS unter "Produktverwaltung - Ihr Produktbereich - Konfigurieren - Allgemeines - Allgemeine Informationen - Pfad" angegebenen Pfad zu Ihrem Webspace, wo die Daten abgelegt werden sollen/sind (z.B. /is/htdocs/wp1234567_ABCDEFGHI, oder wenn Sie einen besonderen Pfad für Ihre Domains festgelegt haben auch z.B. /is/htdocs/wp1234567_ABCDEFGHI/www/nur-ein-beispiel/).
  • Ersetzen Sie jeweils die markierten Teile und:
    • Achten Sie darauf, dass der "system"-Befehl in einer Zeile steht. "system([...]" bis "[...]$fp);"
    • Laden Sie die Datei per FTP hoch und rufen Sie sie per Webbrowser auf.
    • Die Skripte sind so ausgelegt, dass sie die Datenbank "von Null aus" wieder herstellen können. Ein Versuch, eine alte Datenbank in eine bestehende zu importieren schlägt fehl, weil die Tabellen, die angelegt werden sollen schon existieren. Wenn Sie sicher sind, dass Ihr Daten durch die Mischung zweier Zustände konsistent bleiben, können Sie die entsprechenden CREATE TABLE...-Blöcke mit einem Texteditior entfernen und dann den Import durchführen.
    • Das Verzeichnis "dump" sollten Sie im Hauptverzeichnis Ihres Webspaces anlegen.

Export von Datenbanken (Dump)

export.php

<?php
$db_host = 'Datenbankserver';
$db_user = 'Username';
$db_pass = 'Passwort';
$db_name = 'Datenbankname';
$wp_path = 'Pfad zu Ihrem Produkt';

system('/usr/bin/mysqldump -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' >' .$wp_path. 'dump/dump.sql', $fp);
if (($fp==0) && (false !== chmod($wp_path . 'dump/dump.sql', 0666))) {
    echo "Daten exportiert";
} else {
    echo "Es ist ein Fehler aufgetreten";
}
?>

Export von Datenbanken (Dump) als gzip-Archiv

export-zip.php

Sollte Ihr Dump etwas... größer sein, empfiehlt es sich wahrscheinlich, diesen direkt packen zu lassen - das passende Script sieht so aus:

<?php
$db_host = 'Datenbankserver';
$db_user = 'Username';
$db_pass = 'Passwort';
$db_name = 'Datenbankname';
$wp_path = 'Pfad zu Ihrem Produkt';

system('/usr/bin/mysqldump -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' | /bin/gzip >' .$wp_path. 'dump/dump.sql.gz', $fp);
if (($fp==0) && (false !== chmod($wp_path. 'dump/dump.sql.gz', 0666))) {
    echo "Daten exportiert";
} else {
    echo "Es ist ein Fehler aufgetreten";
}
?>

Danach finden Sie in Ihrem Webspace unter "dump" die Datei, die Sie sich herunterladen können.

Import von Datenbanken

import.php

Laden Sie die zu importierende Datei als dump.sql mittels FTP auf Ihren Webspace hoch und nutzen Sie dieses Skript:

<?php
$db_host = 'Datenbankserver';
$db_user = 'Username';
$db_pass = 'Passwort';
$db_name = 'Datenbankname';
$wp_path = 'Pfad zu Ihrem Produkt';

system('/usr/bin/mysql -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' <' .$wp_path. 'dump/dump.sql', $fp);
if ($fp==0) {
    echo "Daten importiert";
} else {
    echo "Es ist ein Fehler aufgetreten";
}
?>

Import von Datenbanken im gzip-Format

import-zip.php

<?php
$db_host = 'Datenbankserver';
$db_user = 'Username';
$db_pass = 'Passwort';
$db_name = 'Datenbankname';
$wp_path = 'Pfad zu Ihrem Produkt';

system('/bin/gunzip -c ' .$wp_path. 'dump/dump.sql.gz | /usr/bin/mysql -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' ', $fp);
if ($fp==0) {
    echo "Daten importiert";
} else {
    echo "Es ist ein Fehler aufgetreten";
}
?>

1044 - Access denied for user user@localhost

Kommt es beim Import zu dieser oder einer ähnlichen Fehlermeldung, kann es sein dass in Ihrem Dumpfile der Befehl CREATE DATABASE enthalten ist. Da Sie nur im KIS, jedoch nicht über Ihren Datenbankbenutzer Datenbanken anlegen können, wird der Import bei dem Befehl CREATE DATABASE mit einem Fehler abgebrochen. Um das Problem zu beheben, öffnen Sie mit einem Editor Ihr Dumpfile und entfernen Sie die Zeile mit dem Befehl CREATE DATABASE. Der Import sollte dann funktionieren.

 

 

English version:

Usually you can easily manage your databases via phpMyAdmin or your own scripts. However, this fails with large amounts of data, since the maximum execution time of a PHP script is limited on the server side (the export script is aborted) and uploading database dumps over 256 MB is not possible. Here are ways you can still import your data:

With MyOOSDumper

With the "MyOOSDumper" program it is possible to create backups of your databases via a web interface. However, this application is not pre-installed and must first be copied to your web space and certain rights set. This is described in the supplied instructions.

Via PHP script (manually)

Please only import data with these scripts that were also created with the same scripts. If you created the dump with phpMyAdmin, for example, problems may arise.

Create a text file with the specified name and content as needed. Please note the following:

  • The subdirectory in which the dump should be saved must be owned by the wp1234567 user..
    • Database server with the name of your DB server, which is usually "localhost".
    • Username with the name of your MySQL user ("dbu"+package number, e.g. "dbu1234567").
    • Password with password you have chosen.
    • Database name with the name of your database (e.g. "db1234567-mydb").
    • Path to your product with the path to your web space specified in the KIS under "Product Admin - *Your Product* - Configure - General - General information", where the data should/are stored (e.g. /is/htdocs/wp1234567_ABCDEFGHI, or if you have defined a special path for your domains, e.g. /is/htdocs/wp1234567_ABCDEFGHI/www/just-an-example/).
  • Replace the marked parts and:
    • Make sure the "system" command is on one line. "system([...]" to "[...]$fp);"
    • Upload the file via FTP and access it via web browser.
    • The scripts are designed in such a way that they can restore the database "from scratch". An attempt to import an old database into an existing one fails because the tables to be created already exist. If you are sure that mixing two states will keep your data consistent, you can use a text editor to remove the appropriate CREATE TABLE...blocks and then perform the import.
    • You should create the "dump" directory in the main directory of your web space.

Export of databases (dump)

export.php

<?php
$db_host = 'Database server';
$db_user = 'User name';
$db_pass = 'Password';
$db_name = 'Database name';
$wp_path = 'Path to your product';

system('/usr/bin/mysqldump -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' >' .$wp_path. 'dump/dump.sql', $fp);
if (($fp==0) && (false !== chmod($wp_path . 'dump/dump.sql', 0666))) {
    echo "export data";
} else {
    echo "An error has occurred";
}
?>

Export of databases (dump) as gzip archive

export-zip.php

If your dump is a bit... larger, it is probably advisable to have it packed directly - the appropriate script looks like this:

<?php
$db_host = 'Database server';
$db_user = 'User name';
$db_pass = 'Password';
$db_name = 'Database name';
$wp_path = 'Path to your product';

system('/usr/bin/mysqldump -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' | /bin/gzip >' .$wp_path. 'dump/dump.sql.gz', $fp);
if (($fp==0) && (false !== chmod($wp_path. 'dump/dump.sql.gz', 0666))) {
    echo "export data";
} else {
    echo "An error has occurred";
}
?>

You will then find the file that you can download in your web space under "dump".

Import of databases

import.php

Upload the file to be imported as dump.sql to your web space via FTP and use this script:

<?php
$db_host = 'Database server';
$db_user = 'User name';
$db_pass = 'Password';
$db_name = 'Database name';
$wp_path = 'Path to your product';

system('/usr/bin/mysql -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' <' .$wp_path. 'dump/dump.sql', $fp);
if ($fp==0) {
    echo "import data";
} else {
    echo "An error has occurred";
}
?>

Import of databases in gzip format

import-zip.php

<?php
$db_host = 'Database server';
$db_user = 'User name';
$db_pass = 'Password';
$db_name = 'Databse name';
$wp_path = 'Path to your product';

system('/bin/gunzip -c ' .$wp_path. 'dump/dump.sql.gz | /usr/bin/mysql -u' .$db_user. ' -p' .escapeshellarg($db_pass). ' -h' .$db_host. ' ' .$db_name. ' ', $fp);
if ($fp==0) {
    echo "import data";
} else {
    echo "An error has occurred";
}
?>

1044 - Access denied for user user@localhost

If this or a similar error message occurs during the import, it may be that the CREATE DATABASE command is contained in your dump file. Since you can only create databases in the KIS, but not via your database user, the import is aborted with an error when the CREATE DATABASE command is issued. To fix the problem, open your dumpfile with an editor and remove the line with the CREATE DATABASE command. The import should then work.


otto.friedrich@hosteurope.de xanthippe.ypsilante@hosteurope.de hercules.ikarus@hosteurope.de