Hi, My site always gets this error: Warning: mysql_connect(): User mydb has already more than 'max_user_connections' active connections in /home/myusername/public_html/config.php on line 7 User mydb has already more than 'max_user_connections' active connections I checked with my programmer, he said the current max user connection is set to 20. How come i get this data access error? i'm loosing tons of users each day because of this error. People using forums site, they have 100's of people online every minute, my sites get 20 people and it starts giving above error. Any solution for this?
Uh.... Tell your programmer to up the max user connection setting? He should have proposed doing so when youa sked about it... -- Derek
Closing your connecton explicitly is always a good practice. If you ask me, he should use pconnect instead of connect. OR explicitly close your connection when you are done at the end of each page.
he did mention that, but he also mention cons, that server load will be high since more people using the site. pconnect? explicity, i think thats already being done for closeing the connection. YOu think maybe couple of pages may have been left out that are not closing the connection?
i was looking on pconnect, it looks same, but it sats open till user browsing, but dont you think once certain amount of user reached, it will give the above error?
When you load a page from a forum or whatever the webserver asks the database for a user, then retrieves some information and sends the results to the client. Once this is done (and it usually takes a fraction of a second) there's no reason to keep that connection to the database open. What's happening here is that the connection is not being closed, it remains open and a new one is open with each new user. Obviously those 20 alloted spaces for users are not going to last long like that. So, at the end of each page tell php to close the connection to the database and it will be freed for a new user. Php keeps track of all the different remote clients, so no information will be mixed. Since each connection only remains open for a fraction of a second each time, those 20 connections can stretch a lot further.
pico /etc/php.ini [MySQL] ; Allow or prevent persistent links. mysql.allow_persistent = On => Off pico /etc/my.cnf set-variable = max_connections=250 # good to stop kids to play skip-networking # i use this but configure based in your hardware key_buffer = 16M myisam_sort_buffer_size = 64M join_buffer_size = 2M read_buffer_size = 2M sort_buffer_size = 3M table_cache = 1500 thread_cache_size = 128 wait_timeout = 15 connect_timeout = 10 max_allowed_packet = 1M max_connect_errors = 10 query_cache_limit = 1M query_cache_size = 16M query_cache_type = 1