Narf03
Posts: 243
Joined: Mon Jun 11, 2012 3:44 pm
Location: Malaysia

Reduce MySQL memory usage

Mon Jan 21, 2013 4:24 pm

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.

Voidious
Posts: 15
Joined: Mon Aug 20, 2012 8:05 pm

Re: Reduce MySQL memory usage

Mon Jan 21, 2013 4:46 pm

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!

Narf03
Posts: 243
Joined: Mon Jun 11, 2012 3:44 pm
Location: Malaysia

Re: Reduce MySQL memory usage

Tue Jan 22, 2013 3:51 pm

already using my-small.cnf (replace the /etc/mysql/my.cnf)

but still using 20% of total memory.

jstoezel
Posts: 6
Joined: Mon Jan 21, 2013 8:15 pm

Re: Reduce MySQL memory usage

Thu Aug 15, 2013 2:57 am

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?

Thanks,
Jean

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: Reduce MySQL memory usage

Thu Aug 15, 2013 5:12 am

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.

Return to “Troubleshooting”