1、查看mysql安装目录
从目录etc/my.cnf中查看安装目录
2、进入mysql目录,停止mysql服务
命令: cd usr/local/mysql
命令:service mysql stop
3、移动整个mysql目录
命令:cp -rf /usr/local/mysql/ home/mysql
4、修改my.cnf文件中mysql位置,并保存
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
datadir=/home/mysql/data
basedir=/home/mysql
socket=/home/mysql/tmp/mysql.sock
lower_case_table_names=1
[mysqld_safe]
log-error=/home/mysql/log/mysqld.log
5、重启服务:
命令: cd usr/local/mysql
命令:service mysql start
遇到问题:
Starting MySQL.The server quit without updating PID file (/home/local/mysql/data/localhost.localdomain.pid).
解决问题:修改/home/local/mysql/data目录权限
修改权限命令: chown -R mysql.mysql /home/local/mysql/data