Chapter 10. The MySQL Data Directory

Conceptually, most relational database systems are broadly similar; they manage a set of databases, and each database includes a set of tables. But every system has its own way of organizing the data it manages, and MySQL is no exception. By default, all information managed by the MySQL server mysqld is stored under a location called the MySQL data directory. All databases are stored here, as well as the status and log files that provide information about the server's operation. If you have any administrative responsibilities for a MySQL installation, familiarity with the layout and use of the data directory is fundamental to carrying out your duties. You can also benefit from reading this chapter even if you don't perform any MySQL administration; it never hurts to have a better idea of how the server operates.

This chapter covers the following topics:

  • How to determine the location of the data directory. You need to know this so that you can administer its contents effectively.

  • How the server organizes and provides access to the databases and tables it manages. This is important for setting up preventive maintenance schedules and for performing crash recovery should table corruption ever occur.

  • What status and log files the server generates and what they contain. Their contents provide useful information about how the server is running, which is useful if you encounter problems.

  • How to change the default location or organization of the data directory. This can be important for managing the allocation of disk resources on your system?for example, by balancing disk activity across drives or by relocating data to file systems with more free space. You can also use this knowledge in planning placement of new databases.

For UNIX systems, the chapter assumes the existence of a login account that is used for performing MySQL administrative tasks and for running the server. In this book, the user and group names for that account are mysqladm and mysqlgrp. The reasons for using a designated login account for MySQL administration are discussed in Chapter 11, "General MySQL Administration."