MySQL Remote Access: How to Connect MySQL Database Remotely using Codeigniter


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.

Remote Database Connection Setup(In Codeigniter):

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: */
    '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

Allowing a Remote Server to Access Your Database(MySQL Remote Access – From cPanel):

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.

  • Log into cPanel and click the Remote MySQL icon, under Databases.


  • Type IP address in the host box, and click the Add Host button.


  • Click Add, and you should now be able to connect remotely to your database.

​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!

phpMyAdmin: How to Import and Export Data using phpMyAdmin

In this post I would like to how can we Import or Export MySQL data using phpMyAdmin.

Topics will be covered in this tutorial:

a.) Import and Export Data.

b.) Export particular selected rows.

c.) Export rows from a particular index(Primary ID).

Import and Export Data:

To import and Export data from phpMyAdmin is very easy just you will get it on a few clicks. Just follow the steps.

To Export Database/Table:

1. Select the database or table you want to import.

Mysql database

2. Click on Export button from top menu.

Export Option in Mysql phpMyAdmin

3. Click on “Go” Button and the download will be start. Before export, custom option you can select For ex: If you want to export only data you can choose the data option so that only records will be exported from the database or table you have choosen.

To Import Database/Table:

Before Import using phpMyAdmin Some of the things you need to remember.

  • Make sure the tables is not exists into database, if the create structure you already have in sql file.
  • Make sure that the same primary key(Unique ID) records is not present in sql file which is already present into database table other wise it will produce error of duplicate entry.

Follow these simple steps to Import using phpMyAdmin.

1. Go to the database.

2. Click on Import option from top.

Import Option in phpMyAdmin

3. Choose the sql file to Import.

4. Click on Go Button. If everything is Ok, then Import will be successfully done.

Export particular selected rows:

To Export particular selected rows from database table you need to select rows you want to export. Please Find Below the screen to understand better how to achieve this.

Export Particular Selected Rows Using Phpmyadmin

Export rows from a particular index(Primary ID):

You can also export data from a particular ID of a table. By running a simple query it will be easy to get all records from a particular Id and after that you can export it.

Query: SELECT  * FROM `table_name`  WHERE id > 27

Export Data From a Particular Id

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 code let us know. We’d love to help!