我得到了一个MySQL数据库文件,我需要将其恢复为Windows Server 2008机器上的数据库。

我尝试使用MySQL管理员,但我得到以下错误:

所选文件由 Mysqldump,不能恢复 这个应用程序。

我如何让它工作?


当前回答

如果要恢复的数据库还不存在,则需要首先创建它。

在命令行中,如果你在包含转储文件的同一个目录中,使用这些命令(使用适当的替换):

C:\> mysql -u root -p

mysql> create database mydb;
mysql> use mydb;
mysql> source db_backup.dump;

其他回答

您也可以使用MySQL管理员中的恢复菜单。你只需要打开备份文件,然后点击还原按钮。

作为前面回答的一个具体例子:

我需要恢复备份,以便导入/迁移到SQL Server。我只安装了MySql,但没有把它注册为服务,也没有把它添加到我的路径中,因为我不需要让它一直运行。

我用windows资源管理器把我的转储文件放在C:\code\dump.sql。然后从开始菜单项中打开MySql。创建DB,然后运行source命令,使用完整路径,如下所示:

mysql> create database temp
mysql> use temp
mysql> source c:\code\dump.sql

我按照下面的步骤来做。

Open MySQL Administrator and connect to server Select "Catalogs" on the left Right click in the lower-left box and choose "Create New Schema" MySQL Administrator http://img204.imageshack.us/img204/7528/adminsx9.th.gif enlarge image Name the new schema (example: "dbn") MySQL New Schema http://img262.imageshack.us/img262/4374/newwa4.th.gif enlarge image Open Windows Command Prompt (cmd) Windows Command Prompt http://img206.imageshack.us/img206/941/startef7.th.gif enlarge image Change directory to MySQL installation folder Execute command: mysql -u root -p dbn < C:\dbn_20080912.dump …where "root" is the name of the user, "dbn" is the database name, and "C:\dbn_20080912.dump" is the path/filename of the mysqldump .dump file MySQL dump restore command line http://img388.imageshack.us/img388/2489/cmdjx0.th.gif enlarge image Enjoy!

./mysql -u <username> -p <password> -h <host-name like localhost> <database-name> < db_dump-file

如果要恢复的数据库还不存在,则需要首先创建它。

在命令行中,如果你在包含转储文件的同一个目录中,使用这些命令(使用适当的替换):

C:\> mysql -u root -p

mysql> create database mydb;
mysql> use mydb;
mysql> source db_backup.dump;