473,800 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php connect to mysql via ssh

I would like to encrypt data passed between my web server and the
database server. I have looked all over, but don't see any information
on how to connect to mysql via ssh with php. Is it possible?

Sep 12 '07 #1
5 4593
On Sep 12, 4:00 pm, mtuller <mitul...@gmail .comwrote:
I would like to encrypt data passed between my web server and the
database server. I have looked all over, but don't see any information
on how to connect to mysql via ssh with php. Is it possible?
You want to use SSH tunneling to do this. Basically, suppose PHP is
running on hostA and MySQL is running on hostB. You then SSH from
hostA to hostB like this:

ssh -L 3306:hostB:3306 hostB

What this says is "From hostA ssh to hostB. When you do that, make
port 3306 on hostA forward everything over to port 3306 on hostB."

Finally you tell PHP to connect to use localhost (hostA) as it's
database server and it should just magically work.

You can even set up the SSH connection on a different machine. So,
from hostC you would do:

ssh -L *:3306:hostB:33 06 hostB

And then configure PHP to use hostC as it's database server.

Sep 12 '07 #2
On Wed, 12 Sep 2007 20:00:33 -0000, mtuller <mi******@gmail .comwrote:
>I would like to encrypt data passed between my web server and the
database server.
How about:

http://www.php.net/manual/en/function.mysql-connect.php

client_flags, MYSQL_CLIENT_SS L
>I have looked all over, but don't see any information
on how to connect to mysql via ssh
Well, you could set up an SSH tunnel for the relevant port (3306, using the -D
flag, or use stunnel or something else like that) and run the standard
(unencrypted) MySQL protocol through the encrypted tunnel, but that's another
step on top of just using the built-in SSL support (assuming a non-ancient
version of MySQL, and that it works as advertised anyway).

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 12 '07 #3
mtuller wrote:
I would like to encrypt data passed between my web server and the
database server. I have looked all over, but don't see any information
on how to connect to mysql via ssh with php. Is it possible?
Try a MySQL newsgroup, such as comp.databases. mysql. MySQL has to be
set up for this communication.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 13 '07 #4
I am not trying to connect via SSL, I want to tunnel through SSH.

On Sep 12, 10:26 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
mtuller wrote:
I would like to encrypt data passed between my web server and the
database server. I have looked all over, but don't see any information
on how to connect to mysql via ssh with php. Is it possible?

Try a MySQL newsgroup, such as comp.databases. mysql. MySQL has to be
set up for this communication.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===

Oct 8 '07 #5
mtuller wrote:
I am not trying to connect via SSL, I want to tunnel through SSH.

On Sep 12, 10:26 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>mtuller wrote:
>>I would like to encrypt data passed between my web server and the
database server. I have looked all over, but don't see any information
on how to connect to mysql via ssh with php. Is it possible?
Try a MySQL newsgroup, such as comp.databases. mysql. MySQL has to be
set up for this communication.

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attg lobal.net
============== ====

You still need to be in a MySQL newsgroup.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 8 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4658
by: pratchaya | last post by:
What the best language code to connect MySQL --> C , C++ , php,VB,Delphi ? about ---- Speed ---- Stable ---- Security Can anyone compare C , C++ , php4,php5 ,vb ,delphi to connect to MySQL ? I need to know how about c++ .
0
2306
by: ryanmhuc | last post by:
I have root access to this server which has been preconfigured. I can connect using the mysql command tool. But I cannot connect using any mysql GUI software (I am currently tunneling the 3306 port to 3306 on the server using SSH). So i ran mysqladmin variables. And got the following: port 0 instead of the usually port 3306. Obviously I cannot connect on port 0. How can I troubleshoot this and get mysql running so I can connect via
2
2747
by: xiuchuanli | last post by:
I install Fedora 4 with web server, after that I installed mysql 5.0.15. Now I can connect to mysql from command line and mysql-administrator and mysql-query-browser. But when I try to test to connect from php code, it told me that "can not connect to local mysql through /tmp/mysql.sock. /tmp/mysql.sock is my sock file to connect and permission is set good. when I add phpinfo() to my php code, it show me that mysql lib php uses is 4.1.X,...
0
1829
by: xiuchuanli | last post by:
I install Fedora 4 with web server, after that I installed mysql 5.0.15. Now I can connect to mysql from command line and mysql-administrator and mysql-query-browser. But when I try to test to connect from php code, it told me that "can not connect to local mysql through /tmp/mysql.sock. /tmp/mysql.sock is my sock file to connect and permission is set good. when I add phpinfo() to my php code, it show me that mysql lib php uses is 4.1.X,...
1
2972
by: shun | last post by:
Hello, I need an sample program to connect mysql server by using odbc. thanks in advance
7
4920
nev
by: nev | last post by:
Can anyone tell me the steps how to do this or direct me to a link? I connect MySQL during runtime. I was wondering if its possible during design time so that I can use the IDE to manage all my MySQL tables.
3
7401
by: likigoldenstar | last post by:
Hi, I have some problem in developing program using PHP. I 'll explain my platforms: I use appserv-win32-2.5.9 as a app server. In the server, mysql client version is 5.0.37 Problems:
3
2543
by: rekhachaturvedi | last post by:
Hi to all. I am new in the web designing. I started using dream weaver mx 2004. I am just able to do design but not able to connect mysql. I am using apache sever. Please explain me how to connect all three for web designing. Thank you so much.
2
1648
by: vaishalinagare | last post by:
when i try to connect mysql database with vb 6.0 i got error Data source name not found and no default driver specified. i'm trying to connect remote database.
1
2284
by: Akinyemi | last post by:
Hi, Please, how do I connect MYSQL to Eclipse? I have made several attempts but fialed. Thank you Akinyemi
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.