Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4110534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:56:48+00:00 2026-05-20T21:56:48+00:00

I’ve created a simple PHP test page which connects to a MySQL database, selects

  • 0

I’ve created a simple PHP test page which connects to a MySQL database, selects one int value, and then frees the result. The page takes 5 seconds or more to load. I’ve seen a lot of posts about this or similar issues but not of the resolutions have worked. Here is the output I’m getting:

mysql_connect took 4.8948628902435 seconds
mysql_select_db 0.00073790550231934 seconds
mysql_query took 0.0013959407806396 seconds
mysql_free_result took 2.0980834960938E-5 seconds

As you can see, the connection takes far too long and everything else is fast.

What I’ve tried

  • Disabled IPv6
  • Used IP instead of FQDN for the MySQL host.
  • Tweaked some config settings.

The Facts

  • All other non-PHP sites respond instantly.
  • Pinging the MySQL server give 1ms latency.
  • Querying the database using MySQL Query Browser gives instant response times.

FYI – I don’t do PHP so it’s okay to treat me like a baby when suggesting fixes.

The Test Script

<?php
    $mtime = microtime();
    $mtime = explode(' ', $mtime);
    $mtime = $mtime[1] + $mtime[0];
    $starttime = $mtime;

    mysql_connect("the_ip||the_hostname", "the_username", "the_password");

    $mtime = microtime();
    $mtime = explode(" ", $mtime);
    $mtime = $mtime[1] + $mtime[0];
    $endtime = $mtime;
    $totaltime = ($endtime - $starttime);
    echo '<h2> mysql_connect took ' .$totaltime. ' seconds</h2>';
?>

Trace route is instantaneous:
By the way, the application in question is MantisBT as well as WordPress.

  1     2 ms    <1 ms    <1 ms  1.2.3.4
  2    <1 ms    <1 ms    <1 ms  MYSQL5 [5.6.7.8]
  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:56:49+00:00Added an answer on May 20, 2026 at 9:56 pm

    Another thing to look at is “mysql_connect” which might show you that PHP is having a hard time resolving (finding) the mysql host. Are you using a IP address, localhost, or hostname? (when connecting to the database in php) If it’s a hostname try and add the IP to c:\windows\system32\drivers\etc\host

    if that doesn’t work.
    If all your “The Facts” are correct then you might have a issue with your php script. Can you post it so I can see what you are running? Also post the mysql table info like “Indexes” etc.

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.