Undo Command in Mysql

epiz_29035681

I was using PHP Mysql. Unfortunately, in a hurry I mistakenly added the below line in my code.
$sql=“update members set mem_name=‘$mem_name’” and I forgot to add where id=‘$id’

Hence, my entire database is changed to only one entry. Can you help me if I can undo this command and get my data back.

Welcome

Unfortunately, there is no “undo” command.

This is why testing on a non-production server is VERY VERY VERY important.

If you happen to have a backup of your database (And you should), you can import that backup. If you don’t have a backup, hopefully this serves as a lesson learned.

5 Likes

That’s a very hard to accept but I did not created any manual backup, isn’t any autobackup system is available in here

Unfortunately not. Since you are not paying anything, we can’t afford the space to store backups.

Premium hosting however, does have this feature.

5 Likes

As Greenreader9 stated, there is no way to roll back your changes. However, I do have one suggestion for the future.

Use:

BEGIN;
/* Your command here */

To save your changes use:
COMMIT;
And to undo your changes use:
ROLLBACK

I’m not sure if this works, however, I do have a vague memory of successfully using this in the InfinityFree servers.

Source:

5 Likes

Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.