Modifying the MySQL database storage directory

Source: Internet
Author: User
Tags vps

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 :

#进入数据库    

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.