Home  >  Article  >  Database  >  mysql 更改数据存放地址

mysql 更改数据存放地址

WBOY
WBOYOriginal
2016-06-07 15:40:201153browse

1、 关闭mysql 服务: service mysqld stop 2 、 转移mysql 数据目录 mv /var/lib/mysql/ /data/ 3 、编辑my.cnf vi /etc/my.cnf 修改其中的datadir 和socket到新的路径 [mysqld] datadir=/data/mysql socket=/data/mysql/mysql.sock 4 、修改sock mkdir -p

1、关闭mysql服务:

service mysqld stop

2、 转移mysql数据目录

mv /var/lib/mysql/ /data/

3、编辑my.cnf

vi /etc/my.cnf

修改其中的datadir和socket到新的路径

[mysqld] 
datadir=/data/mysql 
socket=/data/mysql/mysql.sock

4、修改sock

mkdir -p /var/lib/mysql

ln–s /data/mysql/mysql.sock /var/lib/mysql/mysql.sock

5、重启服务

service mysqld start

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn