Reducing memory consumption of mysql on ubuntu@aws micro instance Reducing memory consumption of mysql on ubuntu@aws micro instance mysql mysql

Reducing memory consumption of mysql on ubuntu@aws micro instance


In your /etc/my.cnf file:

performance_schema = 0

And restart MySQL. This should chop memory usage dramatically if you previously had it on.


Edit: For MySQL versions between 5.7.8 and 8.0.1 (not required from 8.0.1 onwards), the above is not enough to free your memory of performance schema data:

As of MySQL 5.7.8, even when the Performance Schema is disabled, it continues to populate the global_variables, session_variables, global_status, and session_status tables.

(source)

To prevent this behaviour, set show_compatibility_56 to 1 in addition to performance_schema. That is to say, your my.cnf changes should look like:

performance_schema = 0show_compatibility_56 = 1


Change this setting in the MySQL configuration file (my.cnf)

key_buffer              = 8M max_connections         = 30 # Limit connectionsquery_cache_size        = 8M # try 4m if not enough query_cache_limit       = 512Kthread_stack            = 128K


Just to add to the other answer. I recently had this problem myself with the Amazon micro instance (not Ubuntu). The my.cnf file is almost empty so what I did was this:

cp /etc/my.cnf /etc/my.cnf.origcp /usr/share/mysql/my-medium.cnf /etc/my.cnf

Edit my.cnf and enable the innodb lines if applicable. Restart mysqld.

Also the micro instance has no swap, that might be a problem..

SWAPFILE=/mnt/swapfile.swapdd if=/dev/zero of=$SWAPFILE bs=1M count=512mkswap $SWAPFILEswapon $SWAPFILE

Then in /etc/rc.local add:

swapon /mnt/swapfile.swap

To save memory in ruby you might want to use ruby enterprise:

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)gpasswd -a root rvmsource /etc/profile.d/rvm.shrvm get headrvm reloadrvm install reervm --default use ree