dbTalk Databases Forums  

MySql client on Linux - disabling sockets

comp.databases comp.databases


Discuss MySql client on Linux - disabling sockets in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Stephan Carydakis
 
Posts: n/a

Default MySql client on Linux - disabling sockets - 02-27-2007 , 10:34 AM






Hi All,

Due to environment constraints, I have to be able to connect to the local
mysql port (3306) via the hostname "localhost". However, using "localhost"
makes mysql use sockets. This breaks because I don't have a local mysql
server running, hence no socket. I can't seem to find any information about
stopping mysql from using sockets when connecting via "localhost". Can this
be done?

I have inherited code that uses "localhost" to connect to a local mysql
server in the production environment (in about 45 places). In the
development environment, I have a mysql server on a Win2k machine. Because
the code contains connection strings all over the place, I want to be able
to leave the code as is in the development environment and use ssh to
forward port 3306 on localhost to 3306 on Win2k mysql server. I can
successfully do this if I use "127.0.0.1" but it seems the production
environment only allows connections via "localhost" and this can not be
changed.

Any other way around this without having to change connection strings all
the time?

Please reply to the post in comp.databases.

Thanks,

Steph.



Reply With Quote
  #2  
Old   
Lew
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 03-01-2007 , 12:56 AM






Stephan Carydakis wrote:
Quote:
Hi All,

Due to environment constraints, I have to be able to connect to the local
mysql port (3306) via the hostname "localhost". However, using "localhost"
makes mysql use sockets. This breaks because I don't have a local mysql
server running, hence no socket. I can't seem to find any information about
stopping mysql from using sockets when connecting via "localhost". Can this
be done?

I have inherited code that uses "localhost" to connect to a local mysql
server in the production environment (in about 45 places). In the
development environment, I have a mysql server on a Win2k machine. Because
the code contains connection strings all over the place, I want to be able
to leave the code as is in the development environment and use ssh to
forward port 3306 on localhost to 3306 on Win2k mysql server. I can
successfully do this if I use "127.0.0.1" but it seems the production
environment only allows connections via "localhost" and this can not be
changed.
I've used this technique and localhost has always worked fine, if it's defined
in the hosts file as it should be.

You are using 'ssh -L 3306:localhost:3306'?

-- Lew


Reply With Quote
  #3  
Old   
Lew
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 03-01-2007 , 01:02 AM



Stephan Carydakis wrote:
Quote:
Please reply to the post in comp.databases.
Hint: set followups.

-- Lew


Reply With Quote
  #4  
Old   
Lew
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 03-01-2007 , 01:09 AM



Lew wrote:
Quote:
Stephan Carydakis wrote:
Hi All,

Due to environment constraints, I have to be able to connect to the local
mysql port (3306) via the hostname "localhost". However, using
"localhost"
makes mysql use sockets. This breaks because I don't have a local mysql
server running, hence no socket. I can't seem to find any information
about
stopping mysql from using sockets when connecting via "localhost". Can
this
be done?

I have inherited code that uses "localhost" to connect to a local mysql
server in the production environment (in about 45 places). In the
development environment, I have a mysql server on a Win2k machine.
Because
the code contains connection strings all over the place, I want to be
able
to leave the code as is in the development environment and use ssh to
forward port 3306 on localhost to 3306 on Win2k mysql server. I can
successfully do this if I use "127.0.0.1" but it seems the production
environment only allows connections via "localhost" and this can not be
changed.
MySQL checks usernames against the host names from which they log in. Check
how the database user name is defined in MySQL. You might need to explicitly
declare the localhost user base.

-- Lew


Reply With Quote
  #5  
Old   
Stephan Carydakis
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 03-01-2007 , 05:34 AM




"Lew" <lew (AT) nospam (DOT) lewscanon.com> wrote

Quote:
Stephan Carydakis wrote:
Hi All,

Due to environment constraints, I have to be able to connect to the
local
mysql port (3306) via the hostname "localhost". However, using
"localhost"
makes mysql use sockets. This breaks because I don't have a local mysql
server running, hence no socket. I can't seem to find any information
about
stopping mysql from using sockets when connecting via "localhost". Can
this
be done?

I have inherited code that uses "localhost" to connect to a local mysql
server in the production environment (in about 45 places). In the
development environment, I have a mysql server on a Win2k machine.
Because
the code contains connection strings all over the place, I want to be
able
to leave the code as is in the development environment and use ssh to
forward port 3306 on localhost to 3306 on Win2k mysql server. I can
successfully do this if I use "127.0.0.1" but it seems the production
environment only allows connections via "localhost" and this can not be
changed.

I've used this technique and localhost has always worked fine, if it's
defined
in the hosts file as it should be.

localhost is defined in the hosts file.

Quote:
You are using 'ssh -L 3306:localhost:3306'?
Yes. But the problem is not with SSH. Apparently, MySql automatically uses
sockets on Linux when the client connects using "localhost". This takes port
forwarding out of the equation. So how do I tell th MySql client to not uses
sockets?

Quote:
-- Lew
Steph.




Reply With Quote
  #6  
Old   
Lew
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 03-03-2007 , 09:09 AM



Stephan Carydakis wrote:
Quote:
Yes. But the problem is not with SSH. Apparently, MySql automatically uses
sockets on Linux when the client connects using "localhost". This takes port
forwarding out of the equation. So how do I tell th MySql client to not uses
sockets?
I am having trouble understanding what you just said. Port forwarding is all
about sockets. The forwarded 3306 port is forwarded so that socket connections
on the client machine become socket connections on the host machine. That is
hardly "out of the equation". It /is/ the equation.

-- Lew


Reply With Quote
  #7  
Old   
Stephan Carydakis
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 05-27-2007 , 12:00 AM




"Lew" <lew (AT) nospam (DOT) lewscanon.com> wrote

Quote:
Stephan Carydakis wrote:
Yes. But the problem is not with SSH. Apparently, MySql automatically
uses
sockets on Linux when the client connects using "localhost". This takes
port
forwarding out of the equation. So how do I tell th MySql client to not
uses
sockets?

I am having trouble understanding what you just said. Port forwarding is
all
about sockets. The forwarded 3306 port is forwarded so that socket
connections
on the client machine become socket connections on the host machine. That
is
hardly "out of the equation". It /is/ the equation.

Unix sockets have no concept of ports. When using "localhost" to connect to
a MySql server on Linux. it automatically uses sockets. You can not use
sockets to connect to a remote server. You can only use sockets to connect
to a local MySql server. See my predicament?

Quote:
-- Lew



Reply With Quote
  #8  
Old   
toby
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 05-27-2007 , 09:45 AM



On May 27, 2:00 am, "Stephan Carydakis" <scaryda... (AT) nospam (DOT) gmail.com>
wrote:
Quote:
"Lew" <l... (AT) nospam (DOT) lewscanon.com> wrote in message

news:LKadnZ6hXNMREnTYnZ2dnUVZ_hzinZ2d (AT) comcast (DOT) com...



Stephan Carydakis wrote:
Yes. But the problem is not with SSH. Apparently, MySql automatically
uses
sockets on Linux when the client connects using "localhost". This takes
port
forwarding out of the equation. So how do I tell th MySql client to not
uses
sockets?

I am having trouble understanding what you just said. Port forwarding is
all
about sockets. The forwarded 3306 port is forwarded so that socket
connections
on the client machine become socket connections on the host machine. That
is
hardly "out of the equation". It /is/ the equation.

Unix sockets have no concept of ports. When using "localhost" to connect to
a MySql server on Linux. it automatically uses sockets.
Yes, it's a special case; therefore you cannot avoid changing the
connection parameters. The fact that these are duplicated in 45 places
is very poor coding practice, and the most humane solution is to
isolate them in a single function. Do it now and reap the rewards
later. :-)

Quote:
You can not use
sockets to connect to a remote server. You can only use sockets to connect
to a local MySql server. See my predicament?

-- Lew



Reply With Quote
  #9  
Old   
Jerry McBride
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 05-28-2007 , 12:17 PM



Stephan Carydakis wrote:
Quote:
Yes. But the problem is not with SSH. Apparently, MySql automatically
uses
sockets on Linux when the client connects using "localhost". This takes
port
forwarding out of the equation. So how do I tell th MySql client to not
uses
sockets?
A *MySQL* client on Unix can connect to the `mysqld' server in two
different ways: Unix sockets, which connect through a file in the file
system (default `/tmp/mysqld.sock') or TCP/IP, which connects through a
port number. Unix sockets are faster than TCP/IP but can only be used
when connecting to a server on the same computer. Unix sockets are
used if you don't specify a hostname or if you specify the special
hostname `localhost'.

So... don't use locahost, use the actual hostname for tcp/ip connections.



--


Jerry McBride


Reply With Quote
  #10  
Old   
Lew
 
Posts: n/a

Default Re: MySql client on Linux - disabling sockets - 06-03-2007 , 03:45 PM



Stephan Carydakis wrote:
Quote:
"Lew" <lew (AT) nospam (DOT) lewscanon.com> wrote in message
news:LKadnZ6hXNMREnTYnZ2dnUVZ_hzinZ2d (AT) comcast (DOT) com...
Stephan Carydakis wrote:
Yes. But the problem is not with SSH. Apparently, MySql automatically
uses
sockets on Linux when the client connects using "localhost". This takes
port
forwarding out of the equation. So how do I tell th MySql client to not
uses
sockets?
I am having trouble understanding what you just said. Port forwarding is
all
about sockets. The forwarded 3306 port is forwarded so that socket
connections
on the client machine become socket connections on the host machine. That
is
hardly "out of the equation". It /is/ the equation.


Unix sockets have no concept of ports. When using "localhost" to connect to
a MySql server on Linux. it automatically uses sockets. You can not use
sockets to connect to a remote server. You can only use sockets to connect
to a local MySql server. See my predicament?
What confused me is that the term "socket" also applies to IP connections.

If you follow others' advice to use TCP/IP to connect then you'll be able to
use SSH.

--
Lew


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.