• Register
0 votes
109 views

Problem :

I am new to MySQL driver. I am trying to connect to the database server using MySQL driver but I always face the below error.

A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 232

Please find below my settings:

$db['default']['hostname'] = $hostname;
$db['default']['username'] = $username;
$db['default']['password'] = $password;
$db['default']['database'] = $database;
$db['default']['dbdriver'] = 'mysqli';
$db['default']['port']     = "3306";  
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE; 

where
$hostname = 'localhost';
$username = 'myusernamegoeshere';
$password = 'mypasswordgoeshere';
$database = 'mydatabasenamegoeshere'; 

I am using below softwares :

CI 2.0.2, Php 5.3.4, Apache/2.2.17 (Unix), Mysql 5.5.13, mysql.default_port 3306

I am trying to fix above error from past couple of days but unable to find any solution on it.

How can I fix it?

8 4 2
2,300 points

1 Answer

0 votes

Solution :

I had also faced similar issue in the recent past. My php.ini file was behind the issues which I was facing. My mistake was my property mysql.default_socket was pointing to the file for which the directory was not present on a specified path. My property was pointing to the path which looks something like follows user/var/mysql/mysql.sock but in my OSX, my file was actually located in user/tmp/mysql.sock. So I just updated the entry in my php.ini file and restarted my webserver and my issue was resolved.

You can also try to change from below line of code

$db['default']['pconnect'] = TRUE; 

TO below line of code

$db['default']['pconnect'] = FALSE;

in  your /application/config/database.php

Hope above solutions will fix your issue.

5 2 1
4,980 points

Related questions

0 votes
1 answer 74 views
74 views
Problem: I am trying to insert the check box values into my database which are separated by commas. I have basic knowledge of database. But my actual problem is I need to get back my checked values from my database in order to edit relevant code. So my question is ... =>implode(",", $Specilized_category),);   $this->db->insert('tbl_employer', $data); } Kindly help me if you are codeigniter expert.
asked Jul 2 Raphael Pacheco 4.9k points
1 vote
1 answer 141 views
141 views
Problem : I am beginner to CodeIgniter, If I try to execute my code then I face below error Object of class ci_db_mysqli_result could not be converted to string . Please find below my code for your reference. class MyReg extends CI_Controller{     function __construct(){ ... my above query in my model but I often face above error. I am looking for CodeIgniter experts help in fixing above error.
asked Apr 21 stewart 4k points