Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, December 7, 2010

How php.ini limits connections to MySQL

php.ini contains two variables that you need to be aware of:

mysql.max_links = -1
mysql.max_persistent = -1

Setting these values to a number other than -1 (unlimited) in fact enforces a maximum number of connections PER php instance. For example:

If max_links is set to 3 and your script tries to establish more than 3 simultaneous links to various mysql databases, the script will throw a connection error after the 3rd link.

This can be a nasty one to diagnose when all else seems to be working.