After using the VPS for a period of time, you find that the disk space is almost full. My VPS bought a 500GB disk at the time of purchase, and the provider presented a 20GB high-performance system disk. So the system has two disk space. The database directory was installed on the system disk when MySQL was first installed. (first disk) after a period of time, the database storage volume is large, the storage space of 20GB is full. Therefore, the storage space must be changed. Hey, the following is a simple operation.
Operation Steps:
1. Check the MySQL database storage directory:
#进入数据库 Show variables like '%dir% '; #查看sql存储路径 (View the path referred to in the DataDir line) quit;
2. Stop the MySQL service:
/etc/init.d/mysql stop
3. Create a new database hosting directory:
Mkdir/data/mysql
4. Move/copy before storing the database directory files, to the new database storage directory location:
cp-rp/usr/local/mysql/data/*/data/mysql/ #或mv/usr/local/mysql/data/*/data/mysql
5. Modify the MySQL database directory permissions and configuration files:
Chown Mysql:mysql-r/data/mysql/vi/etc/my.cnfdatadir=/data/mysql (developed as a new data storage directory)
6. Start the database service:
/etc/init.d/mysql start
7. The test is successful :
#进入数据库