Professional Web Applications Themes

Replace localhost Unix socket connection by Localhost TCP/IP connection - MySQL

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 doentation, google and newsgroups. Thanks -- Damien Desmarets ...

  1. #1

    Default Replace localhost Unix socket connection by Localhost TCP/IP connection

    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 doentation, 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_at_deviantnetwork.com.asc
    Damien Guest

  2. #2

    Default Re: Replace localhost Unix socket connection by Localhost TCP/IPconnection

    Damien Desmarets wrote: 

    That's an easy one:

    localhost -> Unix socket
    127.0.0.1 -> TCP socket

    HTH
    Kai
    Kai Guest

  3. #3

    Default Re: Replace localhost Unix socket connection by Localhost TCP/IPconnection

    Kai Ruhnau a écrit : 
    >
    > That's an easy one:
    >
    > localhost -> Unix socket
    > 127.0.0.1 -> TCP socket
    >
    > HTH
    > Kai[/ref]
    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_at_deviantnetwork.com.asc
    Damien Guest

  4. #4

    Default Re: Replace localhost Unix socket connection by Localhost TCP/IP connection

    Damien Desmarets <com> wrote: 
    > 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).[/ref]

    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/
    Axel Guest

  5. #5

    Default Re: Replace localhost Unix socket connection by Localhost TCP/IPconnection

    Damien Desmarets wrote: 
    >>
    >>That's an easy one:
    >>
    >>localhost -> Unix socket
    >>127.0.0.1 -> TCP socket
    >>
    >>HTH
    >>Kai[/ref]
    >
    > 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).
    >[/ref]

    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.
    net
    ==================
    Jerry Guest

Similar Threads

  1. Replies: 1
    Last Post: March 24th, 09:21 PM
  2. Help with a socket connection?
    By Martin in forum PHP Development
    Replies: 7
    Last Post: September 7th, 11:13 PM
  3. Flash-PHP Socket Connection
    By root in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: January 21st, 04:43 AM
  4. Replies: 1
    Last Post: September 12th, 04:20 PM
  5. Something simple!? Sessions - admin.localhost to main.localhost
    By Dave Mateer in forum PHP Development
    Replies: 2
    Last Post: July 1st, 07:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139