Changing the data storage path in Linux MySQL

Source: Internet
Author: User

To change the data storage path, you must first modify the configuration, copy the data, and then restart.

1. to ensure data accuracy, it is best to stop the MySQL service or lock MySQL table writes.

/Etc/My. CNF

[Mysqld]
Datadir =/var/lib/MySQL
Socket =/var/lib/MySQL. Sock
User = MySQL

Assume that the new data storage path is/data/mysqldata.

Modify the configuration:

[Mysqld]
# Datadir =/var/lib/MySQL
Datadir =/data/mysqldata
Socket =/var/lib/MySQL. Sock
User = MySQL

2. Copy all the original data to the new path.

CP-A/var/lib/MySQL/*/test/MySQL/data/

3. Change the new path host

Chown MYSQL: MySQL/test/MySQL/Data

4. Restart MySQL service/sbin/service mysqld restart

Note: If you use Amazon cloud, do not use the MySQL path provided by ordinary EBS, And the search speed slows down.

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.