首页 > 代码库 > Mysql datadir change on ubuntu

Mysql datadir change on ubuntu

原配置路径:/var/lib/mysql

需要迁移到 : /data/mysql

1. 修改配置

    vim /etc/mysql/my.cnf

datadir   = /data/mysqllog_error = /data/mysql/error.log

2. 移动原有datadir目录

    sudo mv /var/lib/mysql  /data/mysql

3. 修改  sudo vim /etc/apparmor.d/usr.sbin.mysqld

   所有/var/lib/mysql的 都改成/data/mysql

4. 重启服务

sudo service apparmor restart

sudo service mysql restart

mysql> show variables like "datadir";+---------------+--------------+| Variable_name | Value        |+---------------+--------------+| datadir       | /data/mysql/ |+---------------+--------------+1 row in set (0.00 sec)

 

 5. apparmor相关:访问控制系统

     http://www.cnblogs.com/-Lei/archive/2013/02/24/2923947.html

Mysql datadir change on ubuntu