For whatever reason, the "mysql" database on my windows mysql installation has been deleted. I now have a mysql install that cannot start because the system database is missing, but I cannot find any documentation on recreating this database.

How do I recreate the mysql database (with users) on Windows?

  • Hehe..."whatever reason". Good way to cover your tracks there, wouldn't want to admit you accidentally the whole database.
    – davr
    Oct 21, 2009 at 18:13

3 Answers 3


Reinstall MySQL.

Here's an sql dump from my mysql table: http://www.box.net/shared/js92gum4gh.


On Unix, you would move your existing database data directory out of the way and run mysql_install_db. Unfortunately, according to the MySQL documentation, you don't have this command on Windows. It claims it is unnecessary because Windows distributions include preinitialized mysql and test databases. This would seem to suggest that you do need to reinstall MySQL.

  • If you are on Windows 7 don't forget to delete the folder C:\ProgramData\MySQL after deinstallation - usually it contains the database. If you don't delete it, the database will not be recreated upon installation! Instead you will end up with the old database.
    – Robert
    Sep 1, 2011 at 14:53
  • I have this command on my rather customized version of CentOS and mysql and it says Installing MySQL system tables... OK Filling help tables... OK but doesn't really recreate dropped mysql database (also your link is broken, this one is ok)
    – vladkras
    Oct 18, 2016 at 17:27

I dropped my mysql deafult system database accidentally.

Reinstallation (as accepted answer suggest) is not always possible, so I tried mysql_install_db first from second answer.

Now it's a part of mysqld and you can try mysqld --initialize but not on my version of OS and mysql.

Anyway it didn't help me too. So I've read docs carefully and found

If the data directory does already exist, you are performing an upgrade operation (not an install operation) and should run mysql_upgrade, not mysql_install_db

That did the trick. With mysql_upgrade I've restored all system tables.

ps I have to mention, that it was fresh install of mysql server, so I didn't care about other databases, settings or users. Be carefull!!! You can lose important data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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