Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore MYSQL Dump File with Command Line

Tags:

I have file.sql, and I want to restore it. I found this command:

mysql -u username -p database_name < file.sql

Where should I put 'file.sql' in file system? I'm using Windows and XAMPP. Thank you.

*) The dump file is 3GB++

like image 752
Jeaf Gilbert Avatar asked Mar 25 '11 07:03

Jeaf Gilbert


People also ask

How do I restore a .sql file?

Restore a backup Launch SQL Server Management Studio (SSMS) and connect to your SQL Server instance. Right-click the Databases node in Object Explorer and select Restore Database.... Select Device:, and then select the ellipses (...) to locate your backup file. Select Add and navigate to where your .


2 Answers

You can put it anywhere, where there is enough diskspace available of course.

A good place for this would be either /tmp (on linux or similar) or c:\temp (on windows or similar)

But assuming you use that exact line you need to change your working directory to that which holds the file.

cd /path/where/sql/file/is

And then

mysql -u username -p database_name < file.sql

If you don't have the mysql bin in your PATH you might want to run

/path/to/mysql/bin/mysql -u username -p database_name < file.sql

Or temporarily put the file.sql in the mysql bin directory (not recommended)

Another possible scenario is to point to the file in the filesystem like this

mysql -u username -p database_name < /path/where/sql/file/is/file.sql

PS. If you're on windows you might wanna change the forward slashes to backslashes.

like image 108
Peter Lindqvist Avatar answered Oct 24 '22 21:10

Peter Lindqvist


You can put anywhere in the system but consider to change the command also

mysql -u username -p database_name < /somepath/file.sql
like image 33
Shakti Singh Avatar answered Oct 24 '22 23:10

Shakti Singh