Radial Software

Home Tips MySQL Pipes and Sockets in MySQL

Pipes and Sockets in MySQL

We had a minor issue with the location of the 'socket' file, created by the MySQL server on Linux to support local communication.

The MySQL server (mysqld) supports two methods for allowing client applications (mysql, mysqladmin, mysqldump, etc) to communicate with it; named-pipes and TCP/IP. Of these, TCP/IP is regarded as the most flexible as it allows connections from any device and from any location.

However, TCP/IP connections are slower than named-pipes [for local connections] and can present a significant security risk to the server, as they allow remote access.

Consequently most Linux distributions and many System Administrators either disable TCP/IP support in MySQL entirely, or restrict TCP connections to the localhost only - this is done in the 'my.cnf' configuration file, using the following options:

  [mysqld]
  skip-networking

or:

  [mysqld]
  bind-address=127.0.0.1

The first option disables TCP/IP support completely, while the second enables TCP/IP, but restricts connections to the localhost (127.0.0.1) only - it tells MySQL to 'bind' only to the 'loopback' network adapter.

Our recommendation is to disable TCP/IP entirely (using 'skip-networking' as above) unless you have a specific need for remote server connections - to support remote phpMyAdmin access, for example.

If you do need remote-access, then consider using the 'bind-address' option to restrict connections to internal network cards, if your server has more than one.

Alternatively use a firewall such as iptables, ipchains or firehol to restrict communication to the MySQL TCP port (which defaults to 3306) from known remote hosts only.

You should also ensure that MySQL users can only connect from pre-authorised hosts - in other words there should be no '%' symbols in the 'host' field of the 'mysql.user' table.

Back to our problem - this occurred when we disabled TCP/IP support, forcing all client-applications to connect via the named-pipe. We could see that the MySQL server had created the 'pipe', but unfortunately some clients were looking in the wrong place!

The default location for the MySQL named-pipe is:

  /tmp/mysql.sock

However, this location is often changed from its default setting via the 'my.cnf' file to something more appropriate, such as:

  [mysqld]
  socket=/var/run/mysqld/mysqld.sock

Our problem arose when we upgraded a pre-installed version of MySQL to the latest 'community' release, reconfiguring the location of the 'pipe' file in the process. This was necessary to bring it in line with other MySQL servers installed on other Linux distributions for data-replication purposes.



 

Add your comment

Your name:
Comment:

Opinions

Favorite Programming Language
 

Search


Online

We have 3 guests online

Services

We have significant experience in developing software products for business users in many different sectors - if your business needs an automated solution

Read more...

News

The UK Government has announced that it intends to increasingly adopt 'open-source' software, in preference to traditional 'propriety' software.

Read more...