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