Noob here...regarding mysql connections


#1

I am just learning about php and mysql and i set up a test mysql database with a couple of tables. I created a php file last night to test that I could connect to the database. It worked. I left the page open and went to bed.

However, when I looked at the mysql usage report this morning it said I had 93 connects and 642 queries. How can that be? I haven’t done anything since last night. Is it because the connection is still open after leaving the page open overnight.

Sorry if this is a stupid question…just curious.

Here is my php:

try {
$conn = new PDO(“mysql:host=$servername;dbname=mytest”, $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo “Connected successfully”;
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}

Thanks in advance…Nesto


#2

Did you run this php script in cron?


#3

I’m observing the exact same thing or even worse. I’ve had my account for about 5 days and I see 180 million queries on my MySQL server. I’ve contacted support, wrote up a ticket and they were very nice, and very quick to respond. They attempted to help. However, they couldn’t see anything wrong. I’m still getting as many queries.

I have a VPS, I wonder if something gets counted incorrectly. I am not running anything that would cause this. I have changed my password to a “strong” one.

Any ideas?

Thank you very much.


#4

is your MySQL on a shared server?


#5

Yes, I am on a shared plan. Maybe there were bots or spiders that ran that triggered those kind of numbers? Again…noob.

Nesto


#6

I wouldn’t worry too much about the statistics you see in the MySQL Usage section of the DreamHost Panel. They haven’t been particularly accurate in quite a while, and we’re actually about to stop collecting them altogether.


#7

if it is on a shared server, I doubt it is the statistics of your usage only. It may be the statistics of all users on the same server.

there is nothing much you can do on a shared server.

If it is super slow to run any DB queries very often, you can contact DH support to check the server. Otherwise, you can ignore it.