The example config files can be found here:
/usr/share/doc/mysql-server-5.0/examples
Most of them are gzipped so you'll need to decompress them. Then you can override your existing my.cnf (which is in /etc/mysql I think).
The headers of the files say what they're good for, but here's an online list:
http://brian.moonspot.net/2008/05/06/ex ... cnf-files/
I guess you probably want my-medium.cnf
Just because it was MySQL that ran out of memory doesn't mean that MySQL was the process that was using the most memory. If Apache used up all the RAM and then MySQL tried to allocate some more, MySQL would run out of RAM even though Apache was using most of it.