The short answer
Stop writes, look for any backup (panel backups, dumps, snapshots), and check if binary logging was on. Do not reinstall or restart repeatedly. Ask for help if the data matters.
Stop making it worse
- Stop the application that writes to the database. New data can overwrite what you want back.
- Do not reinstall MySQL, run repair tools or delete the data folder.
- If you can, take a copy of the whole data folder (
/var/lib/mysql) before you try anything.
Look for backups first
- cPanel or Plesk backups, JetBackup, or your own
mysqldumpfiles. - Provider snapshots of the whole server.
- A replica server, if you have one.
- Old dumps in home folders or email attachments.
Are binary logs on?
sudo mysql -e "SHOW VARIABLES LIKE 'log_bin'; SHOW BINARY LOGS;"If binary logging was on and you have an older full backup, you can replay the log up to just before the mistake (point-in-time recovery) with mysqlbinlog. Do this on a copy of the data, not the live server.
Files on disk
With InnoDB, a table can have its own .ibd file. After a DROP, the files are removed and space may be reused quickly. Recovery from raw disk is a specialist job, and the chance falls with every write. Do not install recovery tools on the same disk.
Be honest about the odds
If there is a backup or a binary log, recovery is usually good. With neither, recovery from the disk may be partial or impossible. Nobody can promise it.
Prevent a repeat
- Daily dumps stored on another server, with a tested restore.
- Binary logs turned on, with sensible retention.
- Separate database users with only the rights they need.
Questions people ask
Can a dropped database always be recovered?
No. With a backup or binary logs, often yes. Without them, it depends on what was written to the disk afterwards.
Should I restart MySQL?
Avoid it until you have copied the data folder. A restart may overwrite things.
Can you do it for me?
Yes. Tell us what happened. We work on a copy and tell you honestly what looks possible.