1. Turn off MySQL:
#service mysqld Stop
2. Transfer data:
#cd/var/lib
#ls
#cp-A mysql/mnt/sdb/mysql/
3, modify the configuration file, a bit three:
#vi/etc/my.cnf
Add under [client]
Socket=/mnt/sdb/mysql/mysql.sock
Comment out the previous code
#datadir =/var/lib/mysql
#socket =/var/lib/mysql/mysql.sock
Modified to:
Datadir=/mnt/sdb/mysql
Socket=/mnt/sdb/mysql/mysql.sock
#vi/etc/init.d/mysqld "Modify DataDir's Directory"
Comment out the previous code
#get_mysql_option mysqld datadir "/var/lib/mysql"
Modified to:
Get_mysql_option mysqld datadir "/mnt/sdb/mysql"
#vi/usr/bin/mysqld_safe "Modify DataDir's Directory"
Comment out the previous code
#DATADIR =/var/lib/mysql
Modified to:
Datadir=/mnt/sdb/mysql
4. Need to establish a mysql.sock link:
#ln-S/mnt/sdb/mysql/mysql.sock/var/lib/mysql/mysql.sock
Now that all the changes are complete, start MySQL below
5. #service mysqld Start
This article is from the "Chen Shifei" blog, make sure to keep this source http://chenshifei.blog.51cto.com/11883413/1883938
Modify the MySQL Data directory