MySQL keeps restarting due to running out of memory

MySQL tag, so I'm guessing MySQL. I've had that FUBAR an InnoDB database before.

Sounds like you do not have your configuration optimized at all. Tuning is going to be specific to your database engine. I provided some general recommendations in the post linked below, which would apply to you as well.

How do I set my.cnf in Mysql so that there are no limits to connections?