The default data file storage directory for MySQL is/var/lib/mysql. The following steps are required if you want to move the directory to/home/data:
1. Create a directory under Home mkdir-p/home/data/mysql
2. Stop MYSQLD Service
/etc/init.d/mysqld stop
3. Migrate the contents of the/var/lib/mysql directory below to/home/data/mysql
4. Modifying the MY.CNF configuration file
If there is no MY.CNF configuration file under the/etc/directory, locate the *.cnf file under/usr/share/mysql/, and copy one of them to/etc/and rename it to MY.CNF). The command is as follows:
[Email protected] mysql]# CP/USR/SHARE/MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF
5. Edit the MySQL configuration file/etc/my.cnf
[Mysqld]
Datadir=/home/data/mysql
Socket=/home/data/mysql/mysql.sock
[Client]
Socket=/database/mysql/mysql.sock
In general, users often forget to add [client] segments to modify the client because the MySQL client program will still connect to/var/lib/mysql/ Mysql.sock This socket above, at this time although the database has started normally, using MySQL to connect to the database is still reported to find no/var/lib/mysql/mysql.sock error
6. Modify MySQL startup script/etc/init.d/mysql
Finally, you need to modify the MySQL startup script/etc/init.d/mysql, put it get_mysql_option mysqld datadir "/var/lib/mysql" line, the path in the quotation marks is changed to your current actual storage path: home/ Data/mysql.
7. Restart MySQL Service
/etc/init.d/mysql Rstart
This article from the "Technology is tossing" blog, please be sure to keep this source http://jamswu.blog.51cto.com/6391890/1415160