MySQL corrupts after every server restart

2020-05-01 08:34发布

问题:

I Have a bit of an odd problem. I am running MySQL and Drupal site from a windows environment (not by choice but it is just how things have worked out) and most of the time the site is fine however every time the server is restarted (from updates or for maintenance) The MySQL Database will corrupt.

When I log in to MySQL Work bench I notice that the server status is stopped and when I try to start it I get the error:

ERROR Fatal error: Can't open and lock privilege tables: Can't find file: 'user' (errno: 2 - No such file or directory)

and then MySQL Server fails to restart.

The only way around this problem is to delete data folder in the ProgramData/MySQL and then replace it with a backup from a fresh install of MySQL then import a backup of my tables and recreate my users.

My Question is what is causing MySQL to corrupt at every sever restart and what can I do to prevent this happening moving forward?

回答1:

This occurs when mysql can not find or do not have permissions to user.MYD or user.MYI or user.frm in the data directory. When you start mysql, make sure that these files exist in data directory. You can just copy those files when mysql does not start



回答2:

This worked for me: Stick with the 32 bit.

Uninstall and make sure you then DELETE the mysql-data folder and all its subfolders before installing, and prefer to use the 32 bit (sometimes 64 bit versions are the problem).

(Source)