Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Today, i was absent minded and instead of droping the databases i wanted I wrote

drop database mysql;

What do i do now!?! i didnt do anything else since and i havent closed my session.

Luckily this is just my local computer with no real data. Should i delete mysql data folder? can i undo it? is there a cmd i can do to fix it? is there no real problem and i am freaking out for nothing?

-edit- ok so it WAS my server. Lucky its MY server and not the company server. I only have sites no one visits anyways. Since it was the server, i had twice a day dumps of sites that does rarely changes. I tried using my dump script to dump the db but it got an error. I figure its ok and hasnt been touched in days so i tried to restore it with this

gunzip < mybackup.sql.gz | mysql

I got the error

ERROR 1146 (42S02) at line 12: Table 'mysql.time_zone_name' doesn't exist

Now that i cant restore, what do i do?

share|improve this question
    
    
Sirex: Not at all. If i drop a db, i can restore it. I dropped this specific database and i cant do ANYTHING –  acidzombie24 Feb 11 '11 at 11:47
13  
+1 for "idiot" tag. –  Tom O'Connor Feb 11 '11 at 11:52
    
Whats sad is i know how to fix this under windows... i just unzip the windows noinstall package. –  acidzombie24 Feb 11 '11 at 14:14
    
Funny how we have 8upvotes (and 9 cause i did it too) on that idiot tag comment and only 3ppl actually upvoted the question. Hey... someone removed the idiot tag.... –  acidzombie24 Feb 12 '11 at 1:43

1 Answer 1

The solution you want (and this should work) is to run mysql_install_db as root. or dpkg-reconfigure mysql if you're a deb/ubu user.

Manpage description:

mysql_install_db initializes the MySQL data directory and creates the system tables that it contains, if they do not exist.

share|improve this answer
4  
Remember that users, permissions and privileges will need to be redone, dropping the mysql table made it all go away. –  coredump Feb 11 '11 at 12:14
    
I reckon you could probably reimport those from a backup though. mysql_install_db does the hard part. –  Tom O'Connor Feb 11 '11 at 12:21
    
Tom O'Connor: I am not sure about that. i am getting errors such as error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES). I killall mysqld, purged mysql-server and apt-get install mysql-server. I had to hand restart it because i didnt see any ps up. and when i did i got the error above –  acidzombie24 Feb 11 '11 at 12:23
    
I then tried... well i'll just paste it. pastie.org/1552500 –  acidzombie24 Feb 11 '11 at 12:26
    
Reinstalling is always a nice way to fix it too. –  Tom O'Connor Feb 11 '11 at 12:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.