一、关闭MySQL.
$ service mysqld stop
二、将/data/mysql下的mysql目录mv(移动)到data目录。
mysql> show variables like 'datadir';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| datadir | /data/mysql/ |
+---------------+-----------------+
1 row in set (0.00 sec)
mysql> show variables like 'socket';
+---------------+--------------------------+
| Variable_name | Value |
+---------------+--------------------------+
| socket | /data/mysql/mysql.sock |
+---------------+--------------------------+
1 row in set (0.00 sec)
mysql>
$ mv -R /data/mysql /data/mysql_new
三、修改mysql配置文件/etc/my.cnf。将datadir和socket的路径改为/data/mysql_new目录下。
[mysqld]
#datadir=/data/mysql ------原系统默认路径
datadir=/data/mysql_new ------现有路径
#socket=/data/mysql/mysql.sock ------原socket路径现
socket=/data/mysql_new/mysql.sock ------现有路径
四、启动mysql.
service mysqld start
分享标题:MySQL数据库数据文件路径迁移步骤
网站URL:
http://lszwz.com/article/pdijcc.html