如何将整个备份文件恢复到MySql数据库?

时间:2020-12-26 19:36:17

I have a backup mySQL database file which contains a few table structures and a few default records. But when I try to recover to the new database and new system that I just installed, it fails.

我有一个备份mySQL数据库文件,其中包含一些表结构和一些默认记录。但是当我尝试恢复到刚刚安装的新数据库和新系统时,它就失败了。

How can I recover the file 'db' to mysql?

如何将文件'db'恢复到mysql?

$ mysql --user=root < /media/Iomega_HDD/20110416/db
ERROR 1046 (3D000) at line 22: No database selected
$ mysql --user=root localhost < /media/Iomega_HDD/20110416/db
ERROR 1049 (42000): Unknown database 'localhost'

4 个解决方案

#1


2  

Try:

尝试:

mysql -u root -p DATABASE_NAME_GOES_HERE < input.sql

mysql -u root -p DATABASE_NAME_GOES_HERE

The -p switch tells it you're going to type in a password. Because you HAVE set a password on your MySQL root account, right? Right?

-p开关告诉它你要输入密码。因为您已经在MySQL root帐户上设置了密码,对吧?对?

#2


1  

$ mysql -u root -p
Welcome to the MySQL monitor.
mysql> create database DatabaseName;
mysql> use DatabaseName;
mysql> source /media/Iomega_HDD/20110416/db

#3


0  

mysql -u root -p

mysql -u root -p

then run the backup script source yourscript.backup

然后运行备份脚本源yourscript.backup

#4


0  

You can do this all through the command line.

您可以通过命令行完成所有操作。

$ mysql --user=root databasename < /media/Iomega_HDD/20110416/db

$ mysql --user = root databasename

#1


2  

Try:

尝试:

mysql -u root -p DATABASE_NAME_GOES_HERE < input.sql

mysql -u root -p DATABASE_NAME_GOES_HERE

The -p switch tells it you're going to type in a password. Because you HAVE set a password on your MySQL root account, right? Right?

-p开关告诉它你要输入密码。因为您已经在MySQL root帐户上设置了密码,对吧?对?

#2


1  

$ mysql -u root -p
Welcome to the MySQL monitor.
mysql> create database DatabaseName;
mysql> use DatabaseName;
mysql> source /media/Iomega_HDD/20110416/db

#3


0  

mysql -u root -p

mysql -u root -p

then run the backup script source yourscript.backup

然后运行备份脚本源yourscript.backup

#4


0  

You can do this all through the command line.

您可以通过命令行完成所有操作。

$ mysql --user=root databasename < /media/Iomega_HDD/20110416/db

$ mysql --user = root databasename