ITCity
asked on
apache and mysql too many connections
I am getting this error.
Warning: mysql_pconnect() [function.mysql-pconnect]: Too many connections in /usr/local/www/data/site/m erchant/fu nctions/in cl_mysql.p hp on line 42
Error connecting to localhost #1040: Too many connections
How can i accept more localhost connections?
Thanks
Warning: mysql_pconnect() [function.mysql-pconnect]:
Error connecting to localhost #1040: Too many connections
How can i accept more localhost connections?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
edit /etc/mysql/my.cnf
change or add this value :
max_connections = 100
change or add this value :
max_connections = 100
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mysql_pconnect is fastest since the server can handle enough threads.
Using pconnect, the best value of mysql max_connections is a bit more higher than the apache MaxClients value.
For apache2, find it in /etc/apache2/apache2.conf
Using pconnect, the best value of mysql max_connections is a bit more higher than the apache MaxClients value.
For apache2, find it in /etc/apache2/apache2.conf
ASKER
Inside php.ini this is what i have for mysql. What changes do I make here?
Thanks
Thanks
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1
; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = -1
; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysql.default_port =
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =
; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =
; Maximum time (in seconds) for connect timeout. -1 means no limit
mysql.connect_timeout = 60
; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
; SQL-Errors will be displayed.
mysql.trace_mode = Off
[MySQLi]
; Maximum number of links. -1 means no limit.
mysqli.max_links = -1
; Default port number for mysqli_connect(). If unset, mysqli_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysqli.default_port = 3306
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysqli.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysqli.default_user =
; Default password for mysqli_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysqli.default_pw =
; Allow or prevent reconnect
mysqli.reconnect = Off
[mSQL]
; Allow or prevent persistent links.
msql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
msql.max_persistent = -1
; Maximum number of links (persistent+non persistent). -1 means no limit.
msql.max_links = -1
ASKER
edit /etc/mysql/my.cnf
i could not locate this file here.. How can I locate this file?
thanks
i could not locate this file here.. How can I locate this file?
thanks
run below command or just search using find command.. this should be in /etc/my.cnf
locate my.cnf
For time being you can set it dynamically as I shown in one of my earlier comments
locate my.cnf
For time being you can set it dynamically as I shown in one of my earlier comments
ASKER
I do not use that my.cnf. Not in my Freebsd server.
thanks
thanks
ASKER
i got nothing from locate.mycnf. I think that is for windows servers
find / -iname "my.cnf"
Try this.. if there is no my.cnf on your box..create a sample my.cnf file and under [mysqld] group add the settings which told you i.e
[mysqld]
wait_timeout=240
interactive_timeout=240
max_connections=200
this can be used on linux....
locate my.cnf
on windows MySQ: config file name is my.ini
[mysqld]
wait_timeout=240
interactive_timeout=240
max_connections=200
this can be used on linux....
locate my.cnf
on windows MySQ: config file name is my.ini
ASKER
I got a blank out put for that command as well.
No issues... it seems you have t create one file..
vi /etc/my.cnf and add below line to this file and retsrat MySQL
[mysqld]
wait_timeout=240
interactive_timeout=240
max_connections=200
vi /etc/my.cnf and add below line to this file and retsrat MySQL
[mysqld]
wait_timeout=240
interactive_timeout=240
max_connections=200
On freebsd it seems to be located in /usr/local/etc/my.cnf
And by default, the file is not created.
After creating the my.cnf file, restart mysql :
/usr/local/etc/rc.d/mysql- server restart
And by default, the file is not created.
After creating the my.cnf file, restart mysql :
/usr/local/etc/rc.d/mysql-
ASKER
I made a file called my.cnf and i pasted the following:
[mysqld]
wait_timeout=240
interactive_timeout=240
max_connections=200
I did a /usr/local/etc/rc.d/mysql- server restart
and i got this error:
error: Found option without preceding group in config file: /etc/my.cnf at line: 1
Fatal error in defaults handling. Program aborted
error: Found option without preceding group in config file: /etc/my.cnf at line: 1
Fatal error in defaults handling. Program aborted
[mysqld]
wait_timeout=240
interactive_timeout=240
max_connections=200
I did a /usr/local/etc/rc.d/mysql-
and i got this error:
error: Found option without preceding group in config file: /etc/my.cnf at line: 1
Fatal error in defaults handling. Program aborted
error: Found option without preceding group in config file: /etc/my.cnf at line: 1
Fatal error in defaults handling. Program aborted
ASKER
Does anyone know how to add more connections to mysql?
Please, post your entire my.cnf file here.
ASKER
I do not have a my.cnf. How do I make one?
ASKER
I made a cnf file.
if that dos not work ...
2. try to increase the max connections in php.ini