Restoring a MySQL database

Tags:
Linux
MySQL
MySQL Restore
Perhaps somebody can point me in the right direction. I have a MySQL database that I inadvertently deleted all records from. There is a regular backup I have which I can access, but I have no idea where the MySQL database tables reside in the system. I have the root password and complete access to the commands to restore the files from the backup. I'm just missing the location and have no idea where to look. I'd appreciate any suggestions or pointers.

Answer Wiki

Thanks. We'll let you know when a new response is added.

From a command prompt, you can backup your entire database using this line:

mysqldump -u user_name -p your_password database_name > File_name.sql

Example:
Let’s assume that:
Username: bobbyjoe
Password: happy234
Database Name: BobsData

mysqldump -u bobbyjoe -p happy234 BobsData > BobBackup.sql

This will backup the database to a file called BobBackup.sql

To restore the database CANNOT already exist:

This will only work if the database does not already exist:

mysql – u user_name -p your_password database_name < file_name.sql

Or using our example from the previous page:

mysql – u bobbyjoe -p happy234 BobsData < BobBackup.sql

If your database already exists and you are just restoring it, try this line instead:

mysqlimport -u user_name -p your_password database_name file_name.sql

Or using our example again:

mysqlimport -u bobbyjoe -p happy234 BobsData BobBackup.sql

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Philreenee33
    You may come back mysql database records owing to following way mysql fix application restores mysql data in cases system errors, power failures and etc.
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following