我得到了一个MySQL数据库文件,我需要将其恢复为Windows Server 2008机器上的数据库。
我尝试使用MySQL管理员,但我得到以下错误:
所选文件由 Mysqldump,不能恢复 这个应用程序。
我如何让它工作?
我得到了一个MySQL数据库文件,我需要将其恢复为Windows Server 2008机器上的数据库。
我尝试使用MySQL管理员,但我得到以下错误:
所选文件由 Mysqldump,不能恢复 这个应用程序。
我如何让它工作?
当前回答
我按照下面的步骤来做。
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!
其他回答
我按照下面的步骤来做。
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!
如果你想查看转储的进度,试试这个:
pv -i 1 -p -t -e /path/to/sql/dump | mysql -u USERNAME -p DATABASE_NAME . sh
你当然需要安装“pv”。此命令仅适用于*nix。
使用在Linux上创建的200MB转储文件在Windows w/ mysql 5.5上进行恢复,我使用
source file.sql
方法从mysql提示符比用
mysql < file.sql
在命令行,这导致一些错误2006“服务器已经离开”(在windows)
奇怪的是,在(mysql)安装期间创建的服务引用了一个不存在的my.ini文件。我将“大”示例文件复制到my.ini中 我已经按照建议的增加量进行了修改。
我的价值观是
[mysqld]
max_allowed_packet = 64M
interactive_timeout = 250
wait_timeout = 250
运行命令进入DB
# mysql -u root -p
输入用户密码,然后创建新DB
mysql> create database MynewDB;
mysql> exit
然后退出。Afetr。执行此命令
# mysql -u root -p MynewDB < MynewDB.sql
然后进入db并键入
mysql> show databases;
mysql> use MynewDB;
mysql> show tables;
mysql> exit
就是这样........您的转储将从一个DB恢复到另一个DB
或者还有另一种转储恢复的方法
# mysql -u root -p
然后进入db并键入
mysql> create database MynewDB;
mysql> show databases;
mysql> use MynewDB;
mysql> source MynewDB.sql;
mysql> show tables;
mysql> exit
它应该像运行这样简单:
mysql -u <user> -p < db_backup.dump
如果转储的是单个数据库,您可能需要在文件顶部添加一行:
USE <database-name-here>;
如果它是许多数据库的转储,则use语句已经在其中。
要运行这些命令,打开一个命令提示符(在Windows中),并cd到mysql.exe可执行文件所在的目录(你可能需要四处寻找,这取决于你如何安装mysql,即独立或作为WAMP包的一部分)。进入该目录后,您应该能够像上面那样键入命令。