Re: Relaying MySQL Socket to a remote tcp mysql server
Hello,
... Okay, I am one big big mysql newbie.
In fact, I tested it all using the "root" (eg: the user with all 
privileges) user. Not regular users. And everything wnet fine, yeah.
In fact, all I had to do was to refresh the privileges, or restart the 
mysql server, etc etc... Mysql was still using the former privileges.
The socat thing works.
Okay guys, sorry for wasting your time, i solved my problem on my own :)
See you,
JC
Jean-Christophe Montigny wrote:
Hello,
I currently have a server that serves primarily webpages. As a matter of 
fact, web applications make intensive use of DB backends, and my DB is 
(surprisingly!) MySQL.
Currently the DB server is hosted on the same machine as the web server.
I would like to move the db server to another machine.
Aside from the permission, which is a trivial problem (i can simply move 
permissions from 'localhost' to '%' or the name of the webserver machine 
in mysql authentication system) I would like the move to be transparent 
for users, as is, I'd like them not to have to change their settings and 
still use 'localhost' as the address of the db server in their web 
applications configuration.
PHP uses the mysql socket. My problem is to redirect the socket traffic 
to the remote tcp server.
I have taken a look at sqlrelay, but it seems to be really heavy for my 
small problem. I've tried it, it created the socket, but i didn't really 
get the user / pass thing for listener / db backend.
I then took a look at socat. It created the socket file well, it 
redirected everything. I ran local tests, as is, using the mysql client, 
that accessed the local socket that was redirected to the remote mysql 
server. Everything ran fine.
But then, the php applications crashed... They cannot connect to the 
server... I don't know why. It works for the mysql cli client, but not 
for the php application...
So, here comes my question : is there some specific options to tell 
socat for redirecting a mysql socket in particular, or is there another 
solution ? that is simple ?
Here are the lines I used for socat :
/usr/bin/socat -d -lf/var/log/socat.log \
UNIX-LISTEN:/var/run/mysqld/mysqld.sock,reuseaddr,fork,unlink-early,mode=777,su=nobody,user=mysql,group=mysql 
\
TCP4:bdd.localnet.loc:3306 &
/usr/bin/socat -d -lf/var/log/socat.log \
TCP4-LISTEN:3306,reuseaddr,fork,bind=localhost \
TCP4:bdd.localnet.loc:3306 &
Here are the lines in the socat.log file that appear for some webapps :
2005/12/14 02:27:42 socat[16532] W shutdown(4, 2): Transport endpoint is 
not connected
2005/12/14 02:28:17 socat[16534] W shutdown(4, 2): Transport endpoint is 
not connected
2005/12/14 02:32:26 socat[16589] W shutdown(4, 2): Transport endpoint is 
not connected
Thanks a lot,
--
Jean-Christophe Montigny
Etudiant de troisième année à Grenoble Ecole de Management
Actuellement en parcours ingénieur à l'Ecole Nationale Supérieure de 
Télécommunications de Bretagne
begin:vcard
fn:Jean-Christophe Montigny
n:Montigny;Jean-Christophe
org;quoted-printable:Association Pl@n=C3=A8tes
adr;quoted-printable:;;12, rue Pierre S=C3=A9mard;Grenoble;FR;38000;France
email;internet:jcm@assoces.com
title:Responsable Com Web
x-mozilla-html:FALSE
url:http://planetes.assoces.com/
version:2.1
end:vcard
Reply to: