Welcome Guest, Not a member yet? Register   Sign In
Codeigniter database connection error
#1

Unable to connect to database in Codeigniter:

I have changed mysql to mysqli in database.php but unable to connect to database.

$active_group = 'default';
$query_builder = TRUE;

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

A PHP Error was encountered

Severity: Warning

Message: mysqli::real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.

Filename: mysqli/mysqli_driver.php

Line Number: 201
Reply
#2

We need to know what versions of php, CodeIgniter and your platform that you are running on?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(01-17-2017, 11:09 AM)InsiteFX Wrote: We need to know what versions of php, CodeIgniter and your platform that you are running on?

php version: 5.6.26

CodeIgniter: 3.1.2

WAMP Stack
Reply
#4

@bhanuteja4
Also, are you sure of the password for root? (If you are using a database tool you can check the password by creating an account to access the database.)

Also try 127.0.0.1 in the place of localhost (since you are on Windows).
Reply
#5

Hi @bhanuteja4,
Have you solved the error?
I have the same problem Huh

PHP: 5.4.16 (cli)
codeigniter: 3.1.3
mysql  Ver 14.14 Distrib 5.6.31, for Linux (x86_64) using  EditLine wrapper
Reply
#6

These errors have nothing to do with codeigniter, but your database. Generally this error comes up when you are trying to connect to it over an ip or port which is not allowed. Most of the time, it has to do with the bind address set on your mysql database. This should give you a reference and more information.

http://stackoverflow.com/questions/22736...refused-it
Reply
#7

I had the same error, easily it was the port number of the database in the apache. so you can just check the used port number and add it in database.php file.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB