• Register
0 votes
173 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

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 8 views
8 views
Problem: How do I fix this problem? unable to connect to your database server using the provided settings. codeigniter
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 18 views
0 votes
1 answer 3 views
3 views
Problem: I'm developing a website application using codeigniter at localhost and then i host it in hawkhost. At localhost it runs well, but at host there's and error : Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: ... anything. I also tried to change $db['default']['pconnect'] = FALSE; to true and still doesn't work. Any help please?
asked Apr 2 nabin 3.2k points
0 votes
1 answer 5 views
5 views
Problem: As I mentioned in my previous query, I'm having difficulties with my learning; I've tried searching the web but haven't been able to find adequate information; could you assist me in continuing my project?
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 1 view
1 view
Problem: When I encountered this problem, I attempted to find a solution on the internet but was unable to find any useful details. If you read the above query and understand what the solution is, please cooperate with me- Thanks.
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 3 views
3 views
Problem: The code throws a lot of errors such as : Deprecated: mysql_connect(): The MySQL extension is deprecated and will be removed in the future: use MySQL or PDO instead in C:\wamp\www\btn\index.PHP on line 2 and:- mysqli_fetch_array() error on line 109. What is the problem with the given code? Is there anyone who can help me with this?
asked Mar 22 ummesalma 25.2k points
1 vote
1 answer 15 views
15 views
Problem : When I run this : public function new_pass(){ $email = $this->input->post('email'); $pass1 = $this->input->post('pass1'); $pass2 = $this->input->post('pass2'); $result = $this->db->where('email', $email)->update('user',[ 'pass1' => $pass1, ... this error : Call to a member function num_rows() on boolean in C:\xampp\htdocs\c\application\models\usermodel.php on line 138 what am i missing?
asked Mar 27 Shovo210 13.9k points
1 vote
1 answer 1 view
1 view
Problem : It works on one server very well and on the local machine too. But when I upload that website at the new server I have this errors: Fatal error: Call to undefined function mysqli_init() in /home/blacktwitter/public_html/system/database ... /mysqli_driver.php Line Number: 126 Backtrace:I changed important parameters like database connection, base_url() etc. Any suggestion is welcome!
asked Mar 27 Shovo210 13.9k points