StudentX
StudentX

Reputation: 2323

WAMP Mysqli not working whereas Mysql works

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.

This is my database config settings :

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'studentx',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

If I change 'dbdriver' => 'mysqli', part of the config to 'dbdriver' => 'mysql', then it works with the warning of deprecated mysql extension.

What's going on ?

Upvotes: 0

Views: 2898

Answers (4)

darek
darek

Reputation: 1

I had the same problem, i fixed it by changing localhost to 127.0.0.1

before: 'hostname' => 'localhost',

after: 'hostname' => '127.0.0.1',

Upvotes: 0

mrdragon
mrdragon

Reputation: 247

In php.ini file: find to error_reporting and rewite E_DEPRECATED to E_ALL ^ E_DEPRECATED. Hope this help!

Upvotes: 0

Amitesh Kumar
Amitesh Kumar

Reputation: 3079

Above Answer is also useful .But it may cause same problem if you were
running WAMP with two PHP versions 1) 5.2.9 and 2) 5.2.13. As per site requirement i needed to change PHP version to 5.2.9 from 5.2.13. after swapping PHP version, error was "mysqli extension is missing". after debugging long time i get to know it was due to wrong "extension_dir" path in php.ini file.

So i changed its value:

Old: "extension_dir" c:/wamp/bin/php/php5.2.13/ext/

New: "extension_dir" c:/wamp/bin/php/php5.2.9/ext/

Restarted All services in wamp server, then it's fixed.

Upvotes: 0

Ankit vadariya
Ankit vadariya

Reputation: 1263

First, make sure that the php.ini file is loading the mysqli extension.

How to check Click on wamp icon (taskbar) the icon in the system tray , go to PHP -> PHP Extensions and make sure php_mysqli is checked. If not then go into the php.ini file and make sure that the line: extension=php_mysqli.dll is uncommented (eg, remove the ; if it exists). If that line does not exist, add it.

php.ini path C:\wamp\bin\apache\Apache*..\bin\php.in

Upvotes: 1

Related Questions