Codeigniter: unable to connect to the database server using the provided settings

I use codeigniter as cms framework, if the database host name is localhost, it works correctly.

$db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'root'; $db['default']['password'] = 'test'; $db['default']['database'] = 'jinma'; $db['default']['dbdriver'] = 'mysql'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = TRUE; 

Using the above configuration works correctly, but if the hostname is changed to:

 $db['default']['hostname'] = '192.168.1.222'; 

Database error occurred:

 Unable to connect to your database server using the provided settings. Filename: third_party/fuel/Loader.php Line Number: 134 

and I can ssh 192.168.1.222, Meanwhile in 192.168.1.222 it is also normal when hostname is localhost.

I searched on google and got a solution to add:

 $db['default']['port'] = '3306'; 

but this does not work for me, any idea?

Thank you, this is my first question, sorry for the stupidity.

+4
source share
1 answer

By default, the MySQL server is configured so that it only allows binding with localhost.

Go to my.cnf and comment out the line

 bind 127.0.0.1 

Then you should see that your MySQL user has sufficient permissions to access from other ips.

Remote access to mysql

+7
source

Source: https://habr.com/ru/post/1438589/


All Articles