-2

I'm using a MySQL tuning script that in turn uses the socket (.sock) file on the local drive to connect to MySQL. Even though I have a copy of MySQL on this server, however, the MySQL that I want to work with is actually on a different machine-- in my normal app, the DB_HOST is a different IP address, etc.

So... is there a way to create a socket file that points to a remote MySQL server, that lives on a different IP?

Eric
  • 1,127
  • 3
  • 13
  • 24
  • What, exactly, are you attempting to achieve? – ceejayoz Feb 13 '13 at 22:45
  • Do you mean that you are trying to run either mysqltuner or primer or something similar and have it connect to a remote mysql server? – Tom Geee Feb 13 '13 at 22:51
  • 1
    Yep-- I'm trying to run tuning-primer.sh and it doesn't seem to have an option to connect to a remote server, only to use a socket file. – Eric Feb 14 '13 at 05:02
  • 1
    BTW why the downvotes? This seems like a legit, straightforward non-dupe question that contributes knowledge to the community. :-\ – Eric Feb 14 '13 at 05:03
  • @Eric You're well-advised to use a script that actually uses the MySQL client correctly, such as mysqltuner.pl. Furthermore, automated scripts are no replacement for learning your database workload and what the my.cnf settings do. – Joel E Salas Feb 14 '13 at 07:44
  • 1
    Joel-- thank you for the feedback. I've got mysqltuner working fine, and in this case, I also want to try tuning-primer. I use both of the scripts to get a "second opinion" about the changes I make to my.cnf. Thank you for your comment that I should "learn [my] database workload and what the my.cnf settings do." I agree that these scripts are no replacement for knowing what I'm doing, but I think that they have their place. Which is why I asked my original question... so here we are back at the start. If you know the answer to my question I'd love for you to add it. Thanks. – Eric Feb 14 '13 at 17:40
  • BTW a question to the greater community... what's up with the downvotes? This is a legit, non-duplicate question that adds knowledge to the site. (It seems to be that it's entirely reasonable someone else could come along with this same question, and now ServerFault will be able to help them.) Am I missing something here? – Eric Feb 22 '13 at 02:02

3 Answers3

6

Yes, we call them network connections. Everything you do on the Internet uses them.

Aside from the AF_UNIX socket you are referring to, there are AF_INET sockets and AF_INET6 sockets, which make IPv4 and IPv6 connections, respectively. There are a few other types, but you probably don't care about ancient things like AppleTalk...

Unlike Unix sockets, network sockets do not have corresponding files on the filesystem. They can only be created in application code using the socket API (see the socket(7) man page).

In the case of the tuning scripts, they should have command line options that allow you to specify the remote host to connect to. The popular mysqltuner.pl script, for instance, accepts --host and --port to specify a remote host. (Though specifying the port isn't necessary unless you moved it from the default of 3306).

You still need a username and password with USAGE privileges on the MySQL server, and the firewall must permit you access.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
4

So... is there a way to create a socket file that points to a different IP?

socat - Multipurpose relay: http://www.dest-unreach.org/socat/

poige
  • 9,448
  • 2
  • 25
  • 52
0

The 'socat' answer above will do what you want, but you're better off using the native TCP functionality rather than trying to redirect a UNIX socket, which is designed for high-performance IPC on a single local machine.

To compare, using TCP is like picking up the phone and calling someone, whereas a redirected socket is more like asking a friend to pick up the phone and call them, handing written notes to each other every time something is said. It's unnecessary complication.

dave.io
  • 44
  • 3
  • I hear ya, but like I wrote in my question, I'm using a script that needs a socket. If it were my own code, I might go about it differently-- perhaps exactly as you describe. :-) – Eric Feb 14 '13 at 05:04