This is done in by modifying the lauchd configuration. You can set the maximum number of open files by running the following command in the Terminal:
sudo launchctl limit maxfiles SOFTLIMIT HARDLIMIT
Change the soft limit and hard limit numbers accordingly, or use "unlimited" to specify no limit.
Try this with your current setup, and if you find a value that works for your needs then you can create a launchd configuration file in /etc/ by running the following command:
sudo pico /etc/launchd.conf
In the editor, place the following as a single line in the file:
limit maxfiles SOFTLIMIT HARDLIMIT
...then press Control-O to save, and Control-X to exit, and then reboot to have this value be used.
The default value of "256 unlimited" is the recommended value for this setting, but if you're running into limits with your database then try doubling it until you get to a value that works.