Re-Creating Damaged Grant TablesIf you cannot restore your mysql
grants database from backup, you will need to create afresh 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 thescripts 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_dbor optionally with the user=mysql parameter so that MySQL is configured to run under the mysql system user account
mysql_install_db --user=mysqlResourcesTo learn more about
backing up MySQL databases, seethe Database Backups section of the MySQL manual (
http://dev.mysql.com/doc/mysql/en/backup.html).
Exercises1. SQL dump files are often very large why is this generally not a cause for worry. Setup a weekly backup of all databases on your server. Fora production server, what time would you choose for your regular backups. How can you recover modifications that have been made to your data since the last dump. For an application where any
loss of data is unacceptable, how would you choose the location of your binary logfile?
Exercises | 369