Centos changes the data storage location of mysql

Source: Internet
Author: User

Centos changes the data storage location of mysql

1. Change the data storage location of mysql (Centos)

(1) Turn off mysql

service mysqld stop

(2) Change/etc/my. cnf content

datadir=/newpath/mysql

(3) Restart mysql

service mysqld start

Generally, this step is enough. If not, try the following steps.

2. Change The selinux of the new data storage location

Semanage fcontext-a-t mysqld_db_t "/newpath/mysql (/.*)? "// Set The selinux attribute restorecon-Rv/newpath/mysql of the mysql directory to take effect

3. Change The selinux of the hard disk in NTF format

If the data is stored in the new NTF hard disk, set the selinux value of the root directory (mount point) of the NTF hard disk to system_u: object_r: default_t: s0.

semanage fcontext -a -t default_t /newpath
Restorecon-v/newpath // only change selinux in the root directory

* Note: Changing the selinux attribute of the root directory may overwrite the results in the first 2nd. If you need to re-run the commands in the Second 2nd. 

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.