简体   繁体   中英

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_HDD/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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM