Home > Database > Mysql Tutorial > ubuntu下如何更改mysql数据存放路径_MySQL

ubuntu下如何更改mysql数据存放路径_MySQL

WBOY
Release: 2016-06-01 13:36:05
Original
1144 people have browsed it

Ubuntu

bitsCN.com

ubuntu下如何更改mysql数据存放路径

 

很多时候,mysql的数据会非常大,数据默认放在/var/lib/mysql,由于/var所划分的
空间不够大,所以我们需要将mysql数据存放路径修改一下,放到大分区里面,以便
可以应付mysql数据增长。

1.设置新的存放路径

 

mkdir -p /data/mysql 

 

2.复制原有数据

 

cp -R /var/lib/mysql/* /data/mysql 

 

3.修改权限

 

chown -R mysql:mysql /data/mysql 

4.修改配置文件

 

vim /etc/mysql/my.cnf

datadir         = /data/mysql

 

5.修改启动文件

 

vim /etc/apparmor.d/usr.sbin.mysqld

#把

/var/lib/mysql r,

/var/lib/mysql/** rwk, 

 

#改成

/data/mysql r,

/data/mysql/** rwk, 

 

6.重启服务

 

重启apparmor

 

/etc/init.d/apparmor restart

/etc/init.d/mysql restart 

 

完成

 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template