1

I upgraded from Windows 7 to Windows 10 recently, and installed WAMP. This is my first time working with WAMP.

I am getting following error message in one of my Codeigniter project I was working in windows 7 setup and I don't know what to make of it. The page keeps on loading and loading and then fails with the error message.

Message: mysqli::real_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Further done the page this is the message I get :

Unable to connect to your database server using the provided settings.

The hostname, username, password and database are correct.

But if I change dbdriver to mysql from mysqli then the website loads, but with the following error.

Message: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

What am I doing wrong ?

Note: Oh and yes, I can access phpmyadmin

StudentX
  • 2,243
  • 6
  • 35
  • 67
  • Have you checked that PHP's `mysqli.default_socket` is correct (in php.ini)? – Tristan Dec 07 '15 at 20:05
  • @Tristan It is blank. – StudentX Dec 08 '15 at 03:31
  • That's probably fine, it just means it will use the default. Check that there is no semicolon before `extension=php_mysqli.dll` in your php.ini file – Tristan Dec 08 '15 at 03:36
  • @Tristan no semicolon. – StudentX Dec 08 '15 at 03:47
  • Another check: if your connecting on `localhost`, check your `hosts` file `%SystemRoot%\system32\drivers\etc\host` for `127.0.0.1 localhost` – Tristan Dec 08 '15 at 03:51
  • @Tristan I did change the host file while creating virtual hosts. Here is how it looks now : 127.0.0.1 localhost ::1 localhost 127.0.0.1 dbninja ::1 dbninja 127.0.0.1 Something ::1 Something – StudentX Dec 08 '15 at 03:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/97248/discussion-between-tristan-and-studentx). – Tristan Dec 08 '15 at 03:55
  • Possible duplicate of [Mysqli on WAMP, error - connection attempt failed](http://stackoverflow.com/questions/34325842/mysqli-on-wamp-error-connection-attempt-failed) – StudentX Dec 20 '15 at 13:36

1 Answers1

1

I figured it out and I hope the solution will help someone facing the same problem as me.

Since my server was running slow, I was searching for solutions, I tried a lot of thing but nothing worked, then I changed host name for the database connection from localhost to 127.0.0.1 and it worked. This change made mysqli work and it made my server a lot faster

StudentX
  • 2,243
  • 6
  • 35
  • 67