I have a SQL file generated by MySQLDump. How can I restore it via command prompt?
1- create some dummy tables with at least one column and SAME NAME with frm files in a new mysql database. 3- copy and paste the old frm files to newly created table's frm files, it should ask you if you want to overwrite or not for each. replace all. 4-start mysql service, and you have your table structure...
First you will need to download and connect MySQL Workbench to your database. Once connected you will want to click Server > Data Import: On the next screen you will need to click the bubble for "Import from Self-Contained File", then click on the three dots to find the location of the file on your local machine.
Method 1 – T-SQL The following command is used to restore database called 'TestDB' with backup file name 'TestDB_Full. bak' which is available in 'D:\' location if you are overwriting the existed database.
Run this command (if the mysql
executable isn't in your PATH
, first go to the directory where the MySQL binary is installed, something like \mysql\bin
):
mysql -u username -ppassword databasename < file.sql
(Note that there is no space between -p
and the password)
Or if the file is gzipped (like my backups mostly are) then something like this:
gunzip file.sql.gz | mysql -u username -ppassword databasename
or on some systems it might be necessary to add the -c
flag to gunzip, like so (to force it to output to stdout):
gunzip -c file.sql.gz | mysql -u username -ppassword databasename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With