开发者

How to recover entire backup file to MySql database?

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.

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

$ mysql --user=root < /media/Iomega_HDD/20110416/db
ERROR 1046 (3D000) at line 22: No database selected
$ mysql --user=root localhost < /media/Iomega_H开发者_C百科DD/20110416/db
ERROR 1049 (42000): Unknown database 'localhost'


Try:

mysql -u root -p DATABASE_NAME_GOES_HERE < input.sql

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?


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


mysql -u root -p

then run the backup script source yourscript.backup


You can do this all through the command line.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜