Environment: Ubuntu 12.04 apt-get installed MySQL
Reason: Considering the future of the database will become larger, it is necessary to change the data datadir to large space data disk.
The environment needs to store DataDir under/mnt/mysql_data/mysql
/MNT has mounted a large disk partition
First stop MySQL and mount the disk.
1: Modify /etc/mysql/my.cnf
Modify Datadir=/mnt/mysql_data/mysql
2: Give folder permissions, copy
Need to copy/var/lib/mysql to /mnt/mysql_data/mysql
chmod 777 /mnt/mysql_data/mysql
3: Modify /etc/apparmor.d/usr.sbin.mysqld
Modify the/etc/apparmor.d/usr.sbin.mysqld file
Change "/VAR/LIB/MYSQL/R," to: /mnt/mysql_data/mysql/R,
"/var/lib/mysql/** rwk," modified to: /mnt/mysql_data/mysql/** rwk,
4: Start mysqld
!!! END!!!
This article is from the "on the Road" blog, please be sure to keep this source http://jweiang.blog.51cto.com/8059417/1433659