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?
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.
Reinstall MySQL.
Here's an sql dump from my mysql table: http://www.box.net/shared/js92gum4gh.
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
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.