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
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.
You can restore the dump using phpmyadmin as well but you have to sure that it must be .sql file.
The second way is if you are linux user than use the command line to restore the dump file.
mysql> mysql -uuser_name -ppassword table_name < /path/to/dump_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:\temp\file.sql so your command prompt should look like
C:\temp>
3) now try these command
mysql -u root -p database_name < file.sql
When I execute the answers of this thread, it returns 'mysql' is not recognized as an internal or external command, operable program or batch file.
.
Turned out that I have to execute mysql.exe first in xampp/mysql/bin folder, and the dump file path is relative to this bin folder. I put mine in there, and it worked.
Thanks all.
As an alternate, try to restore the dump with a Restore or with an Execute Large Script Wizard Wizard.
There is a command-line support.
Backup or restore
You can put anywhere in the system but consider to change the command also
mysql -u username -p database_name < /somepath/file.sql