Aug 252014
Article MySQL

In a default MySQL installation on a Linux system, the MySQL data files are located under the /var/lib/mysql directory.

But on many Linux systems, this location might not be the best place. If the system disk is partitioned into several partitions, the size of file system where the ‘/var/lib/mysql’ directory belongs might not be dimensioned to hold the required databases.

Fixing this issue is easy, as explained in this post.

Configuring the directory that holds the MySQL data files

The “datadir” directive in the MySQL configuration file “/etc/mysql/my.cnf” specifies the directory where the datafiles are located.

The default setting for this directive is:

Moving the data files

To move the data files, the database service must be stopped first:

Next, the datafiles are moved to the destination directory. For instance, if a filesystem has been prepared to hold the datafiles, and has been mounted as “/data”:

Next, edit the “/etc/mysql/my.cnf” configuration file to update the value of the “datadir” directive, and finally start again the database service:

And that’s all!

Index of post related to MySQL administration and usage

 Posted by at 5:04 pm

 Leave a Reply