基础环境:CentOS release 5.4 (Final),并且通过yum安装的mysql-server;
data文件路径从默认的/var/lib/mysql调整到/data/mysql,需修改以下几个配置文件:
1,/etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock
2,/etc/init.d/mysqld
get_mysql_option mysqld datadir "/data/mysql"
datadir="$result"
get_mysql_option mysqld socket "$datadir/mysql.sock"
socketfile="$result"
3,/usr/bin/mysqld_safe
#
# Second, try to find the data directory
#
# Try where the binary installs put it
if test -d $MY_BASEDIR_VERSION/data/mysql
then
DATADIR=$MY_BASEDIR_VERSION/data
if test -z "$defaults" -a -r "$DATADIR/my.cnf"
then
defaults="--defaults-extra-file=$DATADIR/my.cnf"
fi
# Next try where the source installs put it
elif test -d $MY_BASEDIR_VERSION/var/mysql
then
DATADIR=$MY_BASEDIR_VERSION/var
# Or just give up and use our compiled-in default
else
DATADIR=/data/mysql
fi
4,ln -s /data/mysql/mysql.sock /var/lib/mysql/mysql.sock (链接)
重启service即可。