Hallo,
Ich hoffe ich finde hier Hilfe und zwar habe ich folgendes problem in der Schule arbeiten wir zurzeit mit Mysql und erstellen Datenbanken wir haben das Programm auf den ust stick installiert leider wurde mir meiner jedoch geklaut und natürlich hab ich jetzt keine Daten mehr nun wollte ich einfach die Datenbanken von einem Freund importieren aber i-wie klappt das nicht so ganz kann mir da jemand helfen?
datenbank importieren
-
Unregistriert -
28. September 2011 um 22:55
-
-
Wo genau liegt das Problem ?
-
Nix einfacher als das.
Exportieren: mysqldump -h hostname -u benutzername -p -x datenbankname > datei.sql
Importieren: mysql -h hostname -u benutzername -p datenbankname < datei.sqlZu beachten ist dabei:
Der Schalter -x beim Export kann eventuell weggelassen werden
Gibt es für den Benutzer kein Passwort, kann man -p weglassen, ansonsten wird man nach dem Passwort gefragtmysqldump und mysql findet man im bin-Verzeichnis der MySQL-Installation
Eine weitere Möglichkeit wäre, aus dem data-Verzeichnis von MySQL das Verzeichnis (Name der Datenbank) einfach zu kopieren und in das data-Verzeichnis des anderen Servers zu kopieren. Das klappt in 99% aller Fälle.
-
Nochwas! Beim Import mit mysql muss die Datenbank schon existieren, ansonsten muss man die vorher anlegen.
-
mhh i-wie klappt das immernoch nicht ganz
Ich habs jetzt so versucht wie beschrieben bekomm jedoch folgende Fehlermeldung:
SQL-Befehl:"1";
MySQL meldet: Dokumentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"1"' at line 1Ich bin leider nicht sehr erfahren was solche sachen betrifft
Danke im vorraus -
Merkwürdig, normalerweise funktioniert das mit einem Dump und Import immer. Bei dir sieht es so aus, als wenn die exportierte Datei nicht in Ordnung ist. Hast du dir die Datei mal angesehen? Bei mir sieht ein Dump so aus:
Code
Alles anzeigen-- MySQL dump 10.13 Distrib 5.1.30, for Win32 (ia32) -- -- Host: localhost Database: test -- ------------------------------------------------------ -- Server version 5.1.30-community /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `test` -- DROP TABLE IF EXISTS `test`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `num1` smallint(2) NOT NULL, `num2` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `test` -- LOCK TABLES `test` WRITE; /*!40000 ALTER TABLE `test` DISABLE KEYS */; INSERT INTO `test` VALUES (1,200,127),(2,3000,127); /*!40000 ALTER TABLE `test` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `test1` -- DROP TABLE IF EXISTS `test1`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `test1` ( `id` int(11) NOT NULL AUTO_INCREMENT, `num1` tinyint(4) NOT NULL, `num2` smallint(6) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `test1` -- LOCK TABLES `test1` WRITE; /*!40000 ALTER TABLE `test1` DISABLE KEYS */; INSERT INTO `test1` VALUES (1,127,1000); /*!40000 ALTER TABLE `test1` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `test2` -- DROP TABLE IF EXISTS `test2`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `test2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `num4` tinyint(4) NOT NULL, `num8` smallint(8) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `test2` -- LOCK TABLES `test2` WRITE; /*!40000 ALTER TABLE `test2` DISABLE KEYS */; /*!40000 ALTER TABLE `test2` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `test3` -- DROP TABLE IF EXISTS `test3`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `test3` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ti` int(11) NOT NULL, `dat` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `test3` -- LOCK TABLES `test3` WRITE; /*!40000 ALTER TABLE `test3` DISABLE KEYS */; /*!40000 ALTER TABLE `test3` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2011-09-29 8:36:27