MySQL默认的数据文件存储目录 /var/lib/mysql,现在要把目录修改为/home/data/mysql cd /home mkdir data //在home目录下建data目录 mysqladmin -u root -p shutdown //停止MySQL服务进程: mv /var/lib/mysql /home/data
MySQL默认的数据文件存储目录 /var/lib/mysql,现在要把目录修改为/home/data/mysqlcd /homemkdir data //在home目录下建data目录mysqladmin -u root -p shutdown //停止MySQL服务进程:mv /var/lib/mysql /home/data/ //移动目录cp /etc/my.cnf /etc/my.cnf //在/etc/目录下找my.cnf配置文件
[如果找不到,可到/usr/share/mysql/下找到*.cnf文件,拷一个到/etc/并改名为my.cnf,cp /usr/share/mysql/my-medium.cnf /etc/my.cnf]编辑MySQL的配置文件/etc/my.cnf,为MySQL能够正常工作,指明mysql.sock文件的产生位置,修改socket=/var/lib/mysql/mysql.sock成为:socket=/home/mysql/mysql.sock
操作过程vi my.cnf# The MySQL server[mysqld]port = 3306#socket = /var/lib/mysql/mysql.sock //原内容,为了稳妥用“#”注释此行,加上下面这行socket = /home/data/mysql/mysql.sock
修改MySQL启动脚本/etc/rc.d/init.d/mysql修改datadir=/var/lib/mysql修改成:datadir=home/data/mysql
重新启动MySQL服务/etc/rc.d/init.d/mysql start或reboot命令重启Linux