I'm using MySQL on Ubuntu Server 15.10.
I've installed MySQL with sudo apt-get install mysql-server
and I'm logging into MySQL as -u root -h localhost
The problem I'm having is that as I add data to my tables, this uses space from the /dev/root
filesystem. As this has a limited amount of space, I need the MySQL server to store things in the /dev/md3
filesystem. The /dev/md3
is the filesystem which files in the /home/user
folder use. I've included a picture to show what the different filesystems look like, generated by typing the command df
.
Image of the filesystems ( df
command).
I have a script that adds rows to a table. When I run this script the number of 1k-blocks in the /dev/root
filesystem decreases and the /dev/md3
filesystem's available 1k-blocks stay constant.
I need MySQL to use the space found in the /dev/md3
not the /dev/root
. This is because the majority of hard drive space is in /dev/md3
. How do I do this?
Things I have tried so far:
datadir = /home/user/mysql
and restarting MySQL. I gave the directory 777 permissions. innodb_data_home_dir = /home/user/mysql
and restarting MySQL. I gave the directory 777 permissions. Both of these attempts haven't yielded any results. Any help will be greatly appreciated.
Thanks
Make sure you execute the following steps one by one
1.) Stop the mysql server: sudo /etc/init.d/mysql stop
2.) Then copy the existing mysql data files to the new location: sudo cp -R -p /var/lib/mysql /home/user/mysql
3.) Add an apparmor alias: edit nano /etc/apparmor.d/tunables/alias
add line with alias /var/lib/mysql/ -> /home/user/mysql
3.1.) Reload apparmor: sudo /etc/init.d/apparmor reload
4.) Edit the datadir
variable nano /etc/mysql/my.cnf
and change it to the new location: datadir=/home/user/mysql
5.) Restart mysql server: sudo /etc/init.d/mysql restart
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.