My suggestion, if you just want to move data between the 2 servers, is to
mysqldump to a file, scp the file to the destination server and then mysql <
filename to get it into the second server.  You can't do it under
programmatic control but it will work and your data will remain secure in

* Cal Evans
* Journeyman Programmer
* Techno-Mage

-----Original Message-----
From: Stefen Lars [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 29, 2002 10:24 AM
Subject: [PHP] Secure MySQL connections in PHP with 'stunnel'

Hello all

I have written a very simple PHP script to copy the data from one MySQL
database table on SERVERA to another MySQL database table on SERVERB.

Using PHP, I simply connect to each server and copy the data across. That
works well.

However, natively, MySQL works with clear text. i.e. the data is copied
across the Internet in clear text (a bad thing).

I would now like encrypt the MySQL data between SERVERA and SERVERB.

After searching with Google, I see that stunnel is a tool to use.

However, I have been trying with no avail to create an encrypted connection
between the two servers from MySQL to work.

Following the instructions at:

I have come up with the following:

SERVERA (master)
/usr/local/sbin/stunnel -f -P/tmp/ -c -d 3308 -r SERVERA:3307
/usr/local/sbin/stunnel -f -P/tmp/ -p /usr/local/ssl/certs/stunnel.pem -d
3307 -r 3306

SERVERB (slave)
/usr/local/sbin/stunnel -f -P/tmp/ -c -d 3308 -r SERVERB:3307
/usr/local/sbin/stunnel -f -P/tmp/ -p /usr/local/ssl/certs/stunnel.pem -d
3307 -r 3306

This does not work. When I connect to the slave with:


$db_link = mysql_connect(SERVERB:3308, "User", "Pwd")
        or die("Cannot connect to db");

        or die("Cannot select MASTER db\n");


and select / insert data into SERVERB, the data is selected / inserted to
the database on SERVERA. This is very strange.

Has anyone else tried using stunnel to achieve what I want to do? If so, I
would REALLY like to hear how you achieve the encrypted link.

Or are there other ways of securely coping data from one MySQL server to

Using stunnel seems rather fiddly…

Any comments on this subject will be well received.


Chat with friends online, try MSN Messenger:

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to