What does mysqldump < do? Live site database mistake, almost shat my pants
I had to delete from some records from a table so before doing that I took this table's backup using mysqldump command. After deleting I realized there has been a mistake开发者_C百科 so I thought to myself...NO PROBLEM....I have the backup so I will restore it. I thought that when you export then you use DATABASE > FILE.SQL so importing would mean DATABASE < FILE.SQL
So I ran the following command:
mysqldump -u USER -p DATABASE < FILE.SQL
And then I realized I have made a mistake because it started displaying all records on screen. Like it's running in verbose mode. I sat there completely still and frozen thinking as to what the hell is happening!!!! because it was even displaying those tables, which I haven't exported earlier. I didn't know whether to stop it or let it complete the process. I waited for about 2, 3 minutes and then pressed Ctrl + C to stop it and prayed to God that everything is fine. Then I checked my database in phpMyAdmin and apparently everything is fine, all tables are present and so is data.
So my question is.....WHAT DID IT DO WHEN I RAN IT WITH < This was a live database and I almost shat my pants trust me!
Thanks
Mysqldump does not take any <
, so it just re-dump your database into your terminal,
and that's the reason your screen is flood with the data (in short, no problem at all)
You use mysqldump to back up a database and mysql to restore it:
mysql -u USER -p DATABASE < FILE.SQL
I don't think it did anything. mysqldump
is a write-only tool and to my knowledge, never accepts command line input. You fed it garbage it didn't understand, no harm done.
精彩评论