user285594
user285594

Reputation:

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'

Upvotes: 1

Views: 1836

Answers (4)

knocte
knocte

Reputation: 17979

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

Upvotes: 1

judda
judda

Reputation: 3972

You can do this all through the command line.

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

Upvotes: 0

Will Martin
Will Martin

Reputation: 4180

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?

Upvotes: 1

Amirshk
Amirshk

Reputation: 8258

mysql -u root -p

then run the backup script source yourscript.backup

Upvotes: 0

Related Questions