Reduce MySQL memory usage

This explenation is for Debian 6.0, may differ slightly for other distros.

First stop MySQL;

/etc/init.d/mysql stop

Create a bash script;

vim /var/


#! /bin/bash
ulimit -s 40
/etc/init.d/mysql start

From now on, start MySQL using this bash script.

But first, alter the MySQL config file;

vim /etc/mysql/my.cnf

In the [mysqld] part of the config, add;


In my case this part looked like this at the end;

user = mysql
pid-file = /var/run/mysqld/
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english

Leave a Reply

Your email address will not be published. Required fields are marked *