• Register
0 votes

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; 

$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

Please log in or register to answer this question.

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 11 views
0 votes
1 answer 295 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, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 288 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, 2020 stewart 4k points
0 votes
1 answer 19 views
Problem: I'm new to php. I need help on how to fetch the data from the database using mysqli. My problem is that there are two databases which are link to each other as master and detail. But I can only design the html. Could anyone show me a php solution based on mysqsli? <!DOCTYPE html> <html> <head> ... td>2</td></tr> <tr><td>2</td><td>Item 2</td><td>1</td></tr> </table> </div> </body> </html>
asked Nov 8, 2020 dorothy 300 points
0 votes
1 answer 12 views
0 votes
1 answer 34 views
I require to know what is parameter is being asked of me to give. Can someone give me the hint how to solve this issue?
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 25 views
This issue stuck in my path "Warning: mysqli_query() expects at least 2 parameters, 1 given". I am finding the solution in several blogs and lot's of opinion coming. Can someone provide me the specific solution and script for solving this issue?
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 12 views