容量规划之MySQL更换数据目录

/ 容量规划Database / 没有评论 / 556浏览

停止mysql

必须的

root@db:~# service mysql stop

转移数据目录&&授权

root@db:~# cp  -rf /old_db_dir/*  /new_db_dir && chown -R mysql.mysql /new_db_dir

改配置

root@db:~# grep datadir /etc/mysql/mysql.conf.d/mysqld.cnf
datadir		= /new_db_dir
#datadir		= /old_db_dir

内核安全配置

增加后面两行

root@db:~# cat /etc/apparmor.d/local/usr.sbin.mysqld
# Site-specific additions and overrides for usr.sbin.mysqld.
# For more details, please see /etc/apparmor.d/local/README.
/db_data/mysql_data/  r,
/db_data/mysql_data/** rwk,

重载配置

root@db:~# service apparmor reload

开启mysql

root@db:~# service mysql start