Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MySQL Error, (Urgent help is neede)


Guest

Recommended Posts

Posted

Hello All

 

I periodically get error on website www.gbn.ge :

 

 

Warning: mysql_connect() [function.mysql-connect]: Too many connections in /mounted-storage/home20a/sub001/sc20035-XVQO/gbn.ge/includes/functions/database.php on line 19

Unable to connect to database server!

 

I thought it was really an error of too many connections, the maximum number of online visitors at the same time was 25, but it did not return an error. I checked and sometiems it returns error when there is only me online :D

 

I am mad do not know what's the problem

 

I contacted to hosting company and he told

 

 

 

Thank you for updating the ticket.

 

Please note that you are allowed to create up to 20 connections at same time per database

 

It seems that your script is generating too many mysql connections at a time. I would like to suggest you a couple of things which you should always keep in mind.

 

1. Check that your PHP code and any other tools always close connections - many database servers require this, and it is good practice.

 

2. Use mysql_connect() instead of mysql_pconnect() unless you have a good reason to do so.

 

3. always put a mysql_close() in the scripts you are using.

 

I hope this helps

 

 

I really did in database.php ---------------------- mysql_pconnect() to mysql_connect()

 

Also one guy suggested to add in application_top php mysql_close(); at the end of php code this before ?> but it error exists

 

can anyone help me why this error comes :(

 

thanks

Posted

20 connections max eh?... Hmmm ... ok.

 

I was a bit curious about your situation and came acrossed this post on the net:

 

The other day a customer reported trouble with their site. The error they were getting was:

 

Warning: mysql_connect() [function.mysql-connect]: Too many connections in

 

I am not sure what really fixed it but this is what I did.

 

I logged into phpmyadmin with the root user. In the Processes tab, i killed all processes

Rebooted by httpd server

Rebooted my mysqld server. I shut it down for like 5 minutes, then start it back up.

I put mysql_close() at the end of every mysql_connect() script. mainli on the footer file.

Since then, I haven't seen the error.

 

- UPDATE: I wanted to know more about this error. In researching I found out what was causing this error. the guilty one was Google. At the time I was getting this error, Google was crawling my site. I was able to find like 15 diffrent Google IP's crawling my site at the same time, which cause an overload on my server. I also added the following code at the end of my scrpt to make sure I close all mysql connection on every page:

 

mysql_close($mysql_connection);

 

* $mysql_connection = whatever variable you use to connect to your mysql.

 

Of course... this may not be your particular problem, but.. it is certainly a place to start looking. I know crawling bots sometimes really swarm in from time to time. Google used to be the one that crawled my site the most each day.. but Yahoo! now is. Just in the past 7 days, Yahoo has hit me 1952 times -vs- Google's 227 times.

 

If you find it realistic that a search engine bot could be the cause... you should think of perhaps setting that particular engine on a crawl delay through your webmaster account with them. (If you have one. If not.. get one).

 

Hope this helps,

 

Iceman :thumbsup:

 

Hello All

 

I periodically get error on website www.gbn.ge :

Warning: mysql_connect() [function.mysql-connect]: Too many connections in /mounted-storage/home20a/sub001/sc20035-XVQO/gbn.ge/includes/functions/database.php on line 19

Unable to connect to database server!

 

I thought it was really an error of too many connections, the maximum number of online visitors at the same time was 25, but it did not return an error. I checked and sometiems it returns error when there is only me online :D

 

I am mad do not know what's the problem

 

I contacted to hosting company and he told

Thank you for updating the ticket.

 

Please note that you are allowed to create up to 20 connections at same time per database

 

It seems that your script is generating too many mysql connections at a time. I would like to suggest you a couple of things which you should always keep in mind.

 

1. Check that your PHP code and any other tools always close connections - many database servers require this, and it is good practice.

 

2. Use mysql_connect() instead of mysql_pconnect() unless you have a good reason to do so.

 

3. always put a mysql_close() in the scripts you are using.

 

I hope this helps

I really did in database.php ---------------------- mysql_pconnect() to mysql_connect()

 

Also one guy suggested to add in application_top php mysql_close(); at the end of php code this before ?> but it error exists

 

can anyone help me why this error comes :(

 

thanks

Posted

Thanks for detailed explanation what to do

 

I will do it as you recommended

 

also one question do I have to delete data base and then back up?

Posted

also I put mysql_connect() at the and of application_top.php but got error :(

Posted

Please explain how can I reboot SQL server

 

what should I do

Posted
Please explain how can I reboot SQL server

 

what should I do

 

I know this does not help your immediate situation, but I would strongly consider when your current hosting plan is due for renewal that you look around for a different company. If they only allow for 20 connections at once you can just about forget getting indexed by Google and most other search engines, I typically have a minimum of 20 google connections on my site at once and have had as many as 140. If you can't get indexed by the search engines its going to be hard to sell product, and if your site does happen to take off and do well then your going to lose customers eventually because they will receive the same error.

 

I presume you chose some sort of economy hosting plan with whomever you use currently, you may want to inquire if they have any other plans with better options so that allow for more connections.

 

As far as rebooting only your hosting company can do that, and if it is a shared server I highly doubt they would do that simply at 1 person's request as it would also effect every other site on the same server, but the only thing you can do is open another ticket and ask them.

Posted
Please explain how can I reboot SQL server

 

you shouldn't need to reboot it. most of the servers are configured to deny the nth connection (in your case 21st) and then block access to the database for a while then reset. just make your code changes and allow things to settle out and you should be fine.

 

kyrsten is right...20 is a low number. they probably use that in order to 'force' almost everyone to upgrade to a more expensive service plan.

 

if it is googlebot doing this, one thing that might help is if you create a sitemap.xml and/or robots.txt to help guide google through your site. its doubtful they need to index every page you have (certainly not your contact us or registration pages anyway) and telling them how often to come back for another pass would cut down on the number of connections.

  • 5 months later...
Posted
Please explain how can I reboot SQL server

 

what should I do

Hi,

 

I too have been experiencing the "Too Many Connections" error even though my site is hosted by one of the big players on a "Professional" hosting plan (clue: they have ONE in their name!). Obviously this is not good for business and I need to consider moving to a more reliable solution based in the UK i.e. not shared. I have scoured the net and find many conflicting recommendations. One user reported that they are on a Virtual Private Server package and are getting a worst database service than when they were on a shared plan... Talk about confusing! I know it's against forum rules to make commercial recommendations so I would welcome any PMs on the subject. Alternatively, I welcome any suggestions about where I can find better providers.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...