Ssh tunnel to remote database for OpenEMR

fndtn357 wrote on Wednesday, May 16, 2012:

I have a question for running various commands that are necessary for the final set up of OpenEMR. I have an OpenEMR on  a local webserver and the database is on a remote server. I created an ssh tunnel for the OpenEMR website to communicate to the remote database.
I am starting to run into a problem with some of the manual configuration.
I was preparing to load and update billing codes and am unable to run the perl script as is.

perl /var/www/openemr/contrib/util/load_icd_desc.plx

If someone has a little more experience or a link to fleshing out the command line to use my ssh tunnel from the local webserver to execute this code against the remote database I would really appreciate it.

mcaloon wrote on Wednesday, May 16, 2012:

Hey fndtn357,
     I have recently been working on replacing the old screen scraper which ran into trouble recently. Please check out this post that might be what you’re running into.

http://sourceforge.net/projects/openemr/forums/forum/202506/topic/5168305?message=11400595

Mac

fndtn357 wrote on Wednesday, May 16, 2012:

Thanks Mac. I appreciate the link, and I will use the resource soon.

My question is in regard to ssh tunneling and how to enable the website and its respective commands to always use the tunnel to speak to the database. What is happening in this line of code is that perl is trying to run a piece of code that interacts with the database.

my $dbh = DBI->connect("dbi:mysql:dbname=$DBNAME", "dbuser", "dbpassword")
 49    or die $DBI::errstr if ($DBNAME);

in particular even hard coding the db connection information alone is not working because the db is not on the same server as the website. Apparently I need to alter this command further to use the tunnel, but I am not sure how to do that yet.

bradymiller wrote on Thursday, May 17, 2012:

Hi,
DBI can connect to other hosts (the above command is going to use localhost); see this page for details how to add the host address to the dbi:mysql:… command:
http://www.tizag.com/perlT/perldbiconnect.php
-brady
OpenEMR

fndtn357 wrote on Thursday, May 17, 2012:

Thanks Brady I’ll check what you posted. What I did do was use the long form of the perl dbconnect command (i.e., “DBI:mysql:database=$database;host=$hostname;port=$port”:wink: which I found on Perlmonks.