Restore MYSQL Dump File with Command Line

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++


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.


你可以放在系统中的任何地方,但也可以考虑改变命令

mysql -u username -p database_name < /somepath/file.sql

The best option will be

1) open the command prompt by Start -> Run -> Command or anyway 2) change you directory where the file.sql is saved say C:tempfile.sql so your command prompt should look like

C:temp> 

3) now try these command

mysql -u root -p database_name < file.sql
链接地址: http://www.djcxy.com/p/30346.html

上一篇: MySQL:如何从命令行导出和导入.sql文件?

下一篇: 使用命令行恢复MYSQL转储文件