MySQL is a popular database along with PHP applications. Sometime we need to connect MySQL Remotely. In this tutorial we will see how to connect MySQL Database Remotely.Let follow me step by step.
To setup database connection in codeigniter application go to the file inside application/config named database.php and change database credentials as showing below.
$db['default'] = array( 'dsn' => '', 'hostname' => 'Use the Remote Server IP Address', /* For Example: 22.214.171.124 */ 'username' => 'Remote MySQL Database User Name', 'password' => 'Remote MySQL Database User Password if Applicable', 'database' => 'Remote MySQL Database Name', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT !== 'production'), 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE );
Before connecting to MySQL from another server or computer, the connecting server or computer must be enabled as an Access Host.To Enable Access Host you need to allow remote server’s IP address. To set IP address go to the cPanel and follow these steps.
That’s All,thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this tutorial let us know. We’d love to help!Tags: cpanel, Mysql Remote Access, server