MySQL database storage path change data file location

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, unreasonable point also please the heroes.

Operation Steps:

1. Check the MySQL database storage directory

Mysql-u Root-prootadmin

#进入数据库

Show variables like '%dir% ';

#查看sql存储路径

(View the path indicated by the DataDir line)

Quit

2. Stop the MySQL service

Service Mysqld Stop

3. Create a new database storage directory

Mkdir/data/mysql

4. Move/copy before storing the database directory files, to the new database storage directory location

Cp-r/usr/local/mysql/data/*/data/mysql/#或mv/usr/local/mysql/data/*/data/mysql

5. Modify MySQL Database directory permissions and configuration files

Chown Mysql:mysql-r/data/mysql/

Vim/etc/my.cnf

Datadir=/data/mysql (developed as a new data storage directory)

Vim/etc/init.d/mysqld

Datadir=/data/mysql

6. Start the database service

Service mysqld Start

Description: Based on the above simple 6-step operation, the database directory has been successfully replaced the path.

Note: The above system is CentOS 6.2 x64 mysql-5.5.13

MySQL database storage path change data file location

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.