centos mysql modifies the database directory


MySQL’s default data file store directory, /var/lib/mysql, is now modified to /home/data/mysql cd /home mkdir data // Build data under home mysqladmin-root-p // Stop the PROCESS of MySQL service: mv/var/lib/mysql/home data / / / move cp/etc/my cnf/etc/my cnf / / in/etc/directory to find my cnf configuration file

[If you cannot find it, go to /usr/share/mysql/ to find *.cnf file, copy 1 to /etc/ and rename it my.cnf, cp usr/share mysql/my - medium. cnf/etc/my cnf ] Edit the configuration file /etc/ my.cnf of MySQL to make MySQL work normally, indicate the location of mysql.sock file. Modify the socket=/var/lib/mysql/mysql.sock Be: socket=/home/mysql/mysql.sock

The operation process vi my cnf # The MySQL server [mysqld] port = 3306 # socket = / var lib/mysql/mysql sock / / the original content, in order to err on the side with ”#” comments on the trip, add the following line socket = / home/data/mysql/mysql sock

Modify MySQL startup scripts/etc/rc d/init d/mysql Modify the datadir=/var/lib/mysql Modified to: datadir=home/data/mysql

Restart the MySQL service / etc rc. d/init. d/mysqlstart Or the reboot command to restart Linux