Because the MySQL database is too large, the default installed var disk can no longer accommodate the newly added data, there is no way, can only find ways to transfer the data directory.
Let me simply tidy up the next few days to the MySQL from the/var/lib/mysql directory under the transfer to/home/mysql_data/mysql under the specific operation
1, first we need to close MySQL, the command is as follows:
&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; Service Mysqld Stop
2, then the transfer of data, in order to secure the period, we use the copy of the command CP, first find the original MySQL directory
Cd/var/lib
ls
After running this command, you will see the MySQL directory, and then execute the CP command
CP mysql/home/mysql_data/
So we can copy the database down to/home/mysql_data.
Note: (-A This parameter must be carried, otherwise the right to copy the past is wrong.) )
If the database is relatively large, time will be longer, may be timed out, how to set up SSH does not time out the way, please find relevant information themselves.
3, then we modify the configuration file, a total of three, the following I one by one description:
Modify first file: Back up Cp/etc/my.cnf/etc/my.cnfbak before modifying
Vi/etc/my.cnf
The directory to modify DataDir after opening is/home/mysql_data/mysql,
Change the socket to/home/mysql_data/mysql/mysql.sock, and for security reasons, you can drop the original annotation and rejoin the line to the current directory.
Modify the second file: Back up Cp/etc/init.d/mysqld/etc/init.d/mysqldbak before modifying
Vi/etc/init.d/mysqld
Note: The exact position is/etc/rc.d/init.d/mysqld, because here is a/etc/init.d to/ETC/RC.D/INIT.D mapping, so use the above command can also be simple.
In the Datadir/var/lib/mysql line, change the path to the right of the equals sign to your current path:/home/mysql_data/mysql
Modify third file: Back up Cp/usr/bin/mysqld_safe/usr/bin/mysqld_safebak before modifying
Vi/usr/bin/mysqld_safe
This is also the directory that modifies datadir for/home/mysql_data/mysql
4, the following need to establish a mysql.sock link:
Ln-s/home/mysql_data/mysql/mysql.sock/var/lib/mysql/mysql.sock
Now that all the changes are complete, let's start MySQL
Service mysqld Start
or reboot Linux
Reboot
If it starts properly, it's basically fine.