dbTalk Databases Forums  

Replace localhost Unix socket connection by Localhost TCP/IP connection

comp.databases.mysql comp.databases.mysql


Discuss Replace localhost Unix socket connection by Localhost TCP/IP connection in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Damien Desmarets
 
Posts: n/a

Default Replace localhost Unix socket connection by Localhost TCP/IP connection - 09-22-2006 , 07:30 AM






Hi
I would like to know how don't use unix socket when i set the hostname
of the mysql database to localhost.
It seems that when you set the hostname to localhost it use by default
the unix socket and not the IP translation for localhost (basicly
127.0.0.1).
I would use the TCP/IP connection to change the localhost IP to a remote
server, with it i have not to change all the clients scripts.

I'm sure i'm not the first to do this but i haven't found the response
on the mysql documentation, google and newsgroups.

Thanks

--

Damien Desmarets 1 place Paul Verlaine
Directeur Technique 92100 Boulogne-Billancourt - France
Deviant Network Tel. : 0 871 100 200
http://www.deviantnetwork.com Fax : 0 871 100 201

GPG : http://www.deviantnetwork.com/damien...etwork.com.asc

Reply With Quote
  #2  
Old   
Kai Ruhnau
 
Posts: n/a

Default Re: Replace localhost Unix socket connection by Localhost TCP/IPconnection - 09-22-2006 , 07:53 AM






Damien Desmarets wrote:
Quote:
I would like to know how don't use unix socket when i set the hostname
of the mysql database to localhost.
It seems that when you set the hostname to localhost it use by default
the unix socket and not the IP translation for localhost (basicly
127.0.0.1).
I would use the TCP/IP connection to change the localhost IP to a remote
server, with it i have not to change all the clients scripts.
That's an easy one:

localhost -> Unix socket
127.0.0.1 -> TCP socket

HTH
Kai


Reply With Quote
  #3  
Old   
Damien Desmarets
 
Posts: n/a

Default Re: Replace localhost Unix socket connection by Localhost TCP/IPconnection - 09-22-2006 , 08:09 AM



Kai Ruhnau a écrit :
Quote:
Damien Desmarets wrote:
I would like to know how don't use unix socket when i set the hostname
of the mysql database to localhost.
It seems that when you set the hostname to localhost it use by default
the unix socket and not the IP translation for localhost (basicly
127.0.0.1).
I would use the TCP/IP connection to change the localhost IP to a remote
server, with it i have not to change all the clients scripts.

That's an easy one:

localhost -> Unix socket
127.0.0.1 -> TCP socket

HTH
Kai
I wan't change all scripts of my clients, they use localhost for the host.
I want mysql to stopping using unix socket for localhost and use the IP
of localhost (changing to a remote server not 127.0.0.1).

--

Damien Desmarets 1 place Paul Verlaine
Directeur Technique 92100 Boulogne-Billancourt - France
Deviant Network Tel. : 0 871 100 200
http://www.deviantnetwork.com Fax : 0 871 100 201

GPG : http://www.deviantnetwork.com/damien...etwork.com.asc


Reply With Quote
  #4  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: Replace localhost Unix socket connection by Localhost TCP/IP connection - 09-22-2006 , 08:54 AM



Damien Desmarets <damienNOSPAMPLEASE (AT) deviantnetwork (DOT) com> wrote:
Quote:
Kai Ruhnau a écrit :

localhost -> Unix socket
127.0.0.1 -> TCP socket

I wan't change all scripts of my clients, they use localhost for the host.
I want mysql to stopping using unix socket for localhost and use the IP
of localhost (changing to a remote server not 127.0.0.1).
That's not possible AFAIK. The "localhost -> socket" rule is hardcoded
in the MySQL client library. You can start mysqld with --skip-socket
to have it not listening on a UNIX socket. But then all your localhost
clients will fail to connect.


XL
--
Axel Schwenke, Senior Software Developer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/


Reply With Quote
  #5  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Replace localhost Unix socket connection by Localhost TCP/IPconnection - 09-22-2006 , 09:32 AM



Damien Desmarets wrote:
Quote:
Kai Ruhnau a écrit :

Damien Desmarets wrote:

I would like to know how don't use unix socket when i set the hostname
of the mysql database to localhost.
It seems that when you set the hostname to localhost it use by default
the unix socket and not the IP translation for localhost (basicly
127.0.0.1).
I would use the TCP/IP connection to change the localhost IP to a remote
server, with it i have not to change all the clients scripts.

That's an easy one:

localhost -> Unix socket
127.0.0.1 -> TCP socket

HTH
Kai

I wan't change all scripts of my clients, they use localhost for the host.
I want mysql to stopping using unix socket for localhost and use the IP
of localhost (changing to a remote server not 127.0.0.1).

Any way you go about it you're going to have to change the code in your
client's scripts. Even if you were able to change localhost to point to
another machine (which you could do in your hosts file but it won't
change MySQL's operation), you may muck up other things on the server -
localhost is supposed to always point at the local machine, and other
apps may depend on it.

You're better off placing the hostname in an include file then using it
in your code, i.e.

hostname.inc.php:
<?php
$hostname='localhost';
?>

clientpage.php:
<?php
include('hostname.inc.php');
...

$link = mysql_connect($hostname,...).
...
?>

Of course, a better way would be to encapsulate the db link in a PHP
class, but that would require more changes to the code.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.