Re-Creating Damaged Grant Tables
If you cannot restore your mysql grants database from backup, you will need to create a
fresh one. With Windows, you can extract the mysql directory from the installation
package and place it under the MySQL data directory.
Under Linux or Mac OS X, you can use the mysql_install_db script to regenerate the
mysql database and the privilege
tables in it. This is particularly handy if your mysql database has somehow become corrupted.
Note that if the user table has to
be created, the root password for
the server will be reset to the default value (blank).
If mysql_install_db isn’t already in your system path, you can generally find it in the scripts directory under your MySQL installation directory. Run mysql_install_db the same way you ran it in Chapter 2. If you’re not sure how to run the script, try logging in as the system superuser and running it with no parameters:
#mysql_install_db
or
optionally with the user=mysql
parameter so that MySQL is configured to run under the mysql system user account:
#mysql_install_db --user=mysql
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access