$time_start = microtime(true); mysqli_connect($host,$username,$password,$db_name); $time_stop = microtime(true); die($time_stop-$time_start); 

returns 1.0171918869019 This is very much what to do?

  • maybe your mysql server is at the other end of the world while connected via a 14400 modem. Then it is still very fast. Or maybe the server is loaded with selects of a couple of megabytes dozens per second. - KoVadim
  • The database is located on the local computer and the script is also running on it, the server load is zero - good_web_master
  • then you need to decide who is guilty - php or base. Connect to the base with handles (for example, via the console or some utility - they often show how much time was spent). Run your script from the console (php filename.php). Maybe you have a firewall? - KoVadim
  • Recommend utility - good_web_master
  • and than standard mysql the client is bad? (console one) - KoVadim

1 answer 1

There is a suspicion that the problem is in dns. Try to connect to 127.0.0.1 instead of localhost and read it.

  • Respect to you, he would not have guessed for anything. Now showing 0.0019030570983887 - good_web_master
  • You can also register in the hosts file correctly. It is even better in many cases. Under linuskom it is already so usual. Under Windows - not always. Where to look for this file - it is written wiki . You need to register the form 127.0.0.1 localhost - KoVadim
  • yes it helps - good_web_master
  • How do I understand this is related to IPv6? - good_web_master
  • This is what I do not know. I only know that the dns client is trying to resolve a "localhost", maybe it first gets an ipv6 address that nobody listens to. - KoVadim