Databases Reference
In-Depth Information
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
Resources
To learn more about backing up MySQL databases, see the “Database Backups” section
of the MySQL manual (
http://dev.mysql.com/doc/mysql/en/backup.html
)
.
Exercises
1. SQL dump files are often very large; why is this generally not a cause for worry?
2. Set up a weekly backup of all databases on your server.
3. For a production server, what time would you choose for your regular backups?
4. How can you recover modifications that have been made to your data since the
last dump?
5. For an application where any loss of data is unacceptable, how would you choose
the location of your binary logfile?