Welcome Guest, Not a member yet? Register   Sign In
Establishing SSH Tunnel to Connect to Remote MySQL Database
#1

[eluser]Unknown[/eluser]
I am refactoring a spaghetti code PHP application into the Codeigniter framework and the development version of the application is on a different server than the production database. For testing, I would like to establish an ssh tunnel from my EC2 instance where I am hosting the development version to the production database. I have successfully created an ssh connection with the remote server via libssh2 AND with phpseclib (http://phpseclib.sourceforge.net/). However, after the ssh tunnel has been established, I am not able to connect to the database with the codeigniter mysqli db driver.

With every attempt to connect to the database, I get the following error:

Unable to connect to your database server using the provided settings. Filename: core/MY_Controller.php Line Number: 6

The MY_Controller code is:

1 <?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3 class MY_Controller extends CI_Controller {
4
5 public function __construct() {
6 parent::__construct();
7 $this->auth = new stdClass;
8 $this->load->library('flexi_auth');
9 if (!$this->flexi_auth->is_logged_in()) {
10 header('Location: /login');
11 }
12 }

I have modified the mysqli driver to include the tunnel object as a parameter in the mysqli real_connect function as follows, to no avail. Does anyone know how I can make this work?

Thank you in advance for any help!

Mike
#2

[eluser]clustersblue[/eluser]
Hi mpduffey,

Were you able to get this to work? I also successfully created a ssh connection but when I load my codeigniter database I get the same error with you.




Theme © iAndrew 2016 - Forum software by © MyBB