Mount MySQL tmpdir as tmpfs for better performance
- Create a directory
#mkdir -p /var/mysqltmp
- Change directory ownership to mysql user
chown mysql:mysql /var/mysqltmp
- Get uid and gid of mysql user
#id mysql
- Edit /etc/fstab to automatically mount tmpfs, add a new line. replace gid and uid
tmpfs /var/mysqltmp tmpfs rw,gid=27,uid=27,size=2G,nr_inodes=50k,mode=0700 0 0
- Mount the filesystems as defined in /etc/fstab
mount -a
- Edit /etc/my.cnf to change tmpdir
[mysqld]
tmpdir = /var/mysqltmp
- Restart mysqld service
#service mysqld restart
- Check if variable is updated in mysql console
SHOW VARIABLES LIKE ‘tmpdir’;
Leave a Reply