Team LiB
Previous Section Next Section

Controlling How the Server Listens for Connections

The MySQL server listens for connections on several network interfaces, which you can control as follows:

  • On all platforms, the server listens on a network port for TCP/IP connections, unless started with the --skip-networking option. The default port number is 3306; to specify a different number, use the --port option. If the server host has more than one IP address, you can specify which one the MySQL server should use when listening for connections by specifying a --bind-address option.

  • Under Unix, the server listens on a Unix domain socket file for connections from local clients that connect to the special hostname localhost or that specify the --protocol=socket option. Use of the socket file by the server cannot be turned off. The default socket file usually is /tmp/mysql.sock, although operating system distributions that include MySQL often use a different location. To specify a socket file pathname explicitly, use the --socket option.

  • When run on Windows NT-based systems, servers with -nt in their names include support for named-pipe connections, although named pipes are disabled by default. To enable this capability, start the server with the --enable-named-pipe option. This allows local clients to connect through the named pipe by specifying the --protocol=pipe option or by connecting to the special hostname "." (period). By default, the pipe name is MySQL; to specify a different name, use the --socket option.

  • As of MySQL 4.1.1, MySQL supports shared-memory connections on Windows. This capability is disabled by default. To enable it, start the server with the --shared-memory option. When enabled, it becomes the default connection protocol for local clients. Local clients also can use the --protocol=memory option to specify use of shared memory explicitly. By default, the shared memory name is MYSQL; to specify a different name, use the --shared-memory-base-name option.

A client that wants to connect to a local server using TCP/IP even when some other protocol might be used by default should specify 127.0.0.1 as the server hostname. That's the address of the TCP/IP loopback interface. Another way to force a TCP/IP connection is to use the --protocol=tcp option.

If you run a single server, it's typical to let the server use its default network settings. If you run more than one server, it's necessary to make sure each one uses unique networking parameters. See "Running Multiple Servers" for more information.

The preceding discussion applies only to standalone servers that operate in a client/server environment. It does not apply to the embedded server, which communicates with the application program that it's linked into by means of an internal channel and does not listen to any external network interfaces at all.

    Team LiB
    Previous Section Next Section