This article describes the MySQL relocation data Directory implementation method. Share to everyone for your reference. The specific methods are as follows:
MySQL allows you to reposition the data directory or its members, and here's how to reposition the MySQL data directory, and interested friends might as well take a look.
Reposition MySQL Data directory
MySQL Data directory structure is the default configuration, all databases and status files are included, however, you have some discretionary data directory content location, here to discuss why you can remove some of the data directory (or even the directory itself), what you can remove and how you do these changes.
MySQL allows you to reposition the data directory or its members for several reasons why you should do this:
You can place the MySQL data directory on a larger file system with the file system that you default to.
If your MySQL data directory is on a busy hard drive, you might put it on a less busy disk to balance disk activity. You can place the database and log files on separate disks or across disks.
You may want to run multiple servers, each with its own data directory, which is one way to resolve each process file descriptor constraint, especially if you cannot reconfigure the kernel to allow for higher limits.
Some systems save part of the server's files, such as/var/run, and you might want to put MySQL's PID file there for consistency in system operations.
MySQL Data Directory relocation method
There are two ways to reposition the contents of the MySQL Data directory:
You can specify options at the server startup, either on the command line or in the [mysqld] of an option file.
You can remove what you want to reposition and then make a symbolic connection to the new location in the original location.
Neither method solves everything you can reposition, and the following table summarizes what can be repositioned and which method to reposition. If you use the option file, it is possible to specify options in the Global options file/etc/my.cnf (c:\my.cnf on Windows). The current version of Windows also looks for the system directory (c:\Windows or C:\NT).
Table Relocation Method
Reposition method for Reposition method
Entire Data directory startup option or symbolic connection
Single Database directory symbolic connection
Single database table symbolic connection
PID File Startup options
General Log startup options
Update log startup options
You can also use the option file My.cnf in the default data directory, but the file is not recommended for use. If you want to reposition the data directory itself, you have to make the default data directory readable so that you can place an option file here specifying where the server should find the "real" Data Directory! It's confusing. If you want to use an option file to specify server options, it is best to use/ETC/MY.CNF.
I hope this article is helpful to the design of MySQL database.