Change the Ubuntu MySQL Data directory location
Most of the time, MySQL data will be very large, the data by default in/var/lib/mysql, because/var partition space is not large enough, so we need to change the MySQL data storage path, put into the large partition, so that can cope with MySQL data growth.
1. Set a new storage path
- Mkdir-p/data/mysql
2. Copy the original data
- Cp-r/var/lib/mysql/*/data/mysql
3. Modify Permissions
- Chown-r Mysql:mysql/data/mysql
4. Modify the configuration file
- Vim/etc/mysql/my.cnf
- DataDir =/data/mysql
5. Modify the Startup file
- Vim/etc/apparmor.d/usr.sbin.mysqld
#把
- /var/lib/mysql R,
- /var/lib/mysql/** Rwk,
#改成
- /data/mysql R,
- /data/mysql/** Rwk,
6. Restart the service
Restart AppArmor
- /etc/init.d/apparmor restart
- /etc/init.d/mysql restart
Turn from: High-feed blog
Change the Ubuntu MySQL Data directory location