MySQL default data file storage directory/var/lib/mysql, now to modify the directory to/home/data/mysql
Cd/home
mkdir data//In the home directory to build the data directory
Mysqladmin-u root-p shutdown//stop MySQL service process:
mv/var/lib/mysql/home/data///Mobile Directory
CP/ETC/MY.CNF/ETC/MY.CNF//Find MY.CNF configuration file in/etc/directory
[If not found, you can find *.cnf files under/usr/share/mysql/, copy one to/etc/and renamed MY.CNF,
Cp/usr/share/mysql/my-medium.cnf/etc/my.cnf
]
Edit MySQL's profile/etc/my.cnf to work properly for MySQL, indicating where the Mysql.sock file will be generated,
Modify
Socket=/var/lib/mysql/mysql.sock
Become:
Socket=/home/mysql/mysql.sock
Operation Process
VI my.cnf
# The MySQL server
[Mysqld]
Port = 3306
#socket =/var/lib/mysql/mysql.sock//original content, in order to safely use the "#" annotation line, plus the following
Socket =/home/data/mysql/mysql.sock
Modify the MySQL startup script/etc/rc.d/init.d/mysql
Modify
Datadir=/var/lib/mysql
Modified into:
Datadir=home/data/mysql
Restart the MySQL service
/etc/rc.d/init.d/mysql start
or reboot command to reboot Linux