MySQL custom modify Data directory path

Source: Internet
Author: User

MySQL default directory in/usr/local/mysql/var, we will modify the directory to/data

1. Stop MySQL

#/etc/init.d/mysql Stop

2. Edit the MySQL configuration file to change the path after DataDir to/data.

Vi/etc/my.sql

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8A/14/wKioL1gl7G2Btz-iAAAeojcdM5E930.png "title=" MySQL Directory modified 1.png "alt=" Wkiol1gl7g2btz-iaaaeojcdm5e930.png "/>

3. Create a directory and modify the user and group to which the directory belongs

# mkdir/data# Chown-r Mysql.mysql/data

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8A/18/wKiom1gl7SHA9GCXAAAIkSiMdjE541.png "title=" MySQL Directory modified 2.png "alt=" Wkiom1gl7sha9gcxaaaiksimdje541.png "/>

4. Copy the data files from the MySQL system to the new directory.

Note: These files must be copied, otherwise the database cannot be started because the system data cannot be found in the new directory.

Cp-a/usr/local/mysql/var/mysql/data

5. Start

#/etc/init.d/mysql Start

Started successfully.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8A/18/wKiom1gl7i3x1ugnAAADd4297Yg478.png "title=" MySQL Directory modified 3.png "alt=" Wkiom1gl7i3x1ugnaaadd4297yg478.png "/>

6. Close the log.

By default, MySQL generates logs for all operations, and mysql-bin.000001 these files takes up a lot of space.

When we do not need to test the environment, can be closed.

Such as.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8A/18/wKiom1gl71zSF1t1AAAZSTYy_qw571.png "title=" MySQL Directory modified 5.png "alt=" Wkiom1gl71zsf1t1aaazstyy_qw571.png "/>


#vi/etc/my.cnf

Found at approximately 31 lines of the file, log-bin the # number before the line, and then restarts MySQL to stop generating the log.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8A/14/wKioL1gl7q_SIMV_AAAPl6auyO0530.png "title=" MySQL Directory modified 4.png "alt=" Wkiol1gl7q_simv_aaapl6auyo0530.png "/>


This article is from the "Enlightened Grocery store" blog, please be sure to keep this source http://wutou.blog.51cto.com/615096/1871969

MySQL custom modify Data directory path

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.