How to change data dir of mysql?

# 1  copy orgin data dir of mysql to new one

cp -R /var/lib/mysql /mysqldata
chown mysql:mysql -R /mysqldata

# 2 modify configure files, search for datadir in file /etc/mysql/my.cnf

#datadir                = /var/lib/mysql
datadir         = /mysqldata


# 3 modify configure files, search  in file /etc/apparmor.d/usr.sbin.mysqld

#  /var/lib/mysql/ r,
#  /var/lib/mysql/** rwk,
  /bmysqldata/ r,
  /mysql_data/** rwk,


# 4 restart your service

service mysql restart

  

posted @ 2016-02-03 16:49  betachen  阅读(182)  评论(0编辑  收藏  举报