How to create a MySQL database on a memory (tmps)

Chgage datadir in /etc/mysql/my.conf to the directory on a tmpfs.
-datadir                = /var/lib/mysql
+datadir                = /dev/shm/mysql
Run the following command to create a DB on a new directory.
# mysql_install_db
Then, launch mysqld.
/etc/init.d/mysqld start

Note

The file created by mysql_install_db will be removed after reboot, so it may be a good idea to write the above setting in /etc/init.d/mysqld to be executed at the beginning. In some cases, such as Ubuntu, access may be restricted by apparmor. In that case, add the following description to /etc/apparmor.d/usr.sbin.mysqld.
  /dev/shm/mysql/** rwk,

No comments:

Post a Comment