i am new in code igniter,
i tried to connect with local db then successfully connected,but while connecting with external db it resulting an error
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/2003): Can't connect to MySQL server on 'xxxxx.gridserver.com' (110)
Filename: mysqli/mysqli_driver.php
Line Number: 202
Backtrace:
File: /var/www/html/restapi/application/libraries/REST_Controller.php
Line: 375
Function: __construct
File: /var/www/html/restapi/application/controllers/Project.php
Line: 26
Function: __construct
File: /var/www/html/restapi/index.php
Line: 292
Function: require_once
i am not familiar with mysql,
i searched more for it, but i have no idea what they speaking about it,
is there anything to do for external db connecton
Thank you in advance!
Check your config->database.php to ensure the
$db['default']['hostname'],$db['default']['username'],$db['default']['password'],$db['default']['database'] are set correctly.
Anther possibility is you're trying to connect a MySQL server remotely but the server itself is blocking remote connection. So make sure that you are able to connect your mysql database using the same set of host, username, password through Mysql client software such as "MySQL Workbench"
As stated by Tan See Youu, it's likely that you may have incorrect credentials in the database.php or indeed named remote connection is being blocked by the server. Though in some cases hosts offer tunnles to be used to allow remote connections through a secured connection. You might want to ask your hosting if they have a SSH tunnel that you could use if they do block direct connections.
1.Check your application/config/database.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost', // your database machine name, this could have localhost, ip address or domain name.
'username' => 'yourmysluser',
'password' => 'yourmysqlpassword',
'database' => 'yourdb',
'dbdriver' => 'mysqli',
- Check your mysql database, by default remote access to the MySQL database server is disabled for security reason. However, some time you nee to provie remote access to database server from home or a web server. You can enable remote mysql access with mysql console or phpmyadmin or another database tool dependent your host.
refer to this :
Enable remote MySQL connection: ERROR 1045 (28000): Access denied for user
and
https://www.youtube.com/watch?v=xXOq9U9fzOo