Is it possible to load a database in the RAM?

Go To


I want to load a MYSQL-database into the RAM of my computer, is there a way to do this? I am running this database under Linux. Also, if this is possible, is there a good way to make backups, because if the computer is unexpectedly shut down, I would lose all my data.

2009-06-16 10:09
by NoName
How to do this in a Windows system - Standin.Wolf 2017-12-04 17:27


If you buffer pool is big enough, you data is -- effectively -- an in-memory database with a disk backup copy. Don't fool around with RAM databases, simply make the buffer pool size as large as you can make it.

Read this:

2009-06-16 10:26
by S.Lott


Yes, you can use the MEMORY engine. As far as backups, it's your call. You never said, e.g. how often you want to store to disk. But you can use traditional MySQL replication or your own solution.

2009-06-16 10:11
by Matthew Flaschen
But when you shutdown the Mysqlserver all rows stored in MEMORY tables are los - jitter 2009-06-16 10:14
Yes, jitter, that's true. It's morke's call how to handle that - Matthew Flaschen 2009-06-16 10:36


absolutely, for example under linux you can mount your database in a tmpfs

2009-06-16 10:11
by dfa
This could be a viable solution if you are capable of doing regular snapshots to backup the database. Else in case of a crash the DB is lost as on reboot, everything in a tmpfs will be los - jitter 2009-06-16 10:16
This works great for running tests! : - Mark 2013-08-31 07:13


If you're using innodb tables then I recommend adjusting the buffer pool size like S.Lott suggested above. Make it 110% or so of your database size if you have the ram.

If your database is > 50mb you'll also want to look at increasing the innodb_log_file_size. See Perhaps to around 25 - 50% of your buffer pool size, but 1gb max.

The innodb_log_file_size is a bit tricky to adjust. You need to shut the db down, move the current log files into a backup location, and let mysql recreate them when it's restarted (i.e. after you've changed the values in my.cnf). Google it and you'll find some answers.

2009-06-16 11:44
by Tim Haines