Page 1 of 1

Reduce MySQL memory usage

Posted: Mon Jan 21, 2013 4:24 pm
by Narf03
I am using a 256MB version of pi, 64MB assigned to GPU, so left over 192MB of system memory.

I have disabled swap file to extend the life of the pi, and to improve performance.

Installed MySQL, it took 20-25% of the left over memory which should be around 36-48MB, while my database shouldnt be more than 1MB of storage.

Attempted to modify the configuration file of MySQL to reduce its memory usage, but failed, its still take almost the same amount of memory.

Need to know are there any other method to reduce MySQL memory usage without disable features of MySQL ? Thanks.

Re: Reduce MySQL memory usage

Posted: Mon Jan 21, 2013 4:46 pm
by Voidious
I'm not a MySQL wizard myself, but I did go through this recently while configuring MySQL on a VPS with 256 MB RAM. Since that (MySQL / VPS) is a pretty common scenario, there's actually quite a lot of info out there for how to configure MySQL for lower memory usage.

First I'd take a look if there's a pre-loaded config to try. On my VPS I have in "/usr/share/doc/mysql-server-5.1/examples/" a bunch of configs, "my-small.cnf", "my-medium.cnf", etc. These can be copied to /etc/mysql/my.cnf.

That didn't really work for me, though. I just played with dialing down a bunch of the buffer sizes and such. Here are some of my settings:

Code: Select all

key_buffer              = 1M
max_allowed_packet      = 1M
table_cache = 1
sort_buffer_size = 16K
read_buffer_size = 16K
read_rnd_buffer_size = 1K
net_buffer_length = 1K
thread_stack            = 128K
thread_cache_size       = 8
# * Query Cache Configuration
query_cache_limit       = 1M
query_cache_size        = 1M
Good luck!

Re: Reduce MySQL memory usage

Posted: Tue Jan 22, 2013 3:51 pm
by Narf03
already using my-small.cnf (replace the /etc/mysql/my.cnf)

but still using 20% of total memory.

Re: Reduce MySQL memory usage

Posted: Thu Aug 15, 2013 2:57 am
by jstoezel
This topic is rather old but I thought I'd give it a try.

As far as I have been able to figure out, I only have one my.cnf file in my installation and it is located in /etc/mysql. I've modified this file, replaced it with examples from the mysql example folder, I've even tried installing my.cnf files in other folders that are parsed by mysql, I've restarted mysql several times, rebooted as well. Nothing seems to change the values for the options displayed using mysql -help.

Has anybody been able to effectively change the configuration parameters of mysql?


Re: Reduce MySQL memory usage

Posted: Thu Aug 15, 2013 5:12 am
by tonyhughes
Any particular reason you need 64MB for the GPU?

Are you running headless, or using the Raspberry Pi's desktop? If headless, crank your GPU down to 16MB.