How to run multiple MySQL servers at the same time

Source: Internet
Author: User

If you want to run multiple servers, the easiest way is to recompile the server with different TCP/IP ports and socket files, so they do not listen on the same TCP/IP Port or socket.
Assume that an existing server is configured as the default port number and socket file, use the configure command line to set the new server:

Shell>./configure -- With-TCP-Port = port_number
-- With-Unix-socket = file_name
-- Prefix =/usr/local/mysql-3.22.9

Port_number and file_name should be different from the default port number and socket file path, and
-- Prefix value should specify an installation directory different from the existing MySQL installation.

you can use this command to check the socket and port used by any currently executed MYSQL:
shell> mysqladmin-H hostname -- Port = port_number variables
if you have a MySQL server running on your port, you will get a table of some of the most important
configurable variables of MySQL, including the socket name.
You should also edit the initialization script (probably "mysql. Server") of your machine to start and kill multiple mysqld servers.
You Don't Have To re-compile a new MySQL server. You only need to start it with a different port and socket. You can change the port and socket by specifying the options used by safe_mysqld at runtime:
shell>/path/to/safe_mysqld -- socket = file_name -- Port = port_number
if you run the new server in the same database directory as the server on which logs are enabled, you should also use the -- log and -- log-update options of safe_mysqld to specify the log file name. Otherwise, the two servers may be attempting to write the same log file.

warning: You should never have two servers that update data in the same database! If your OS does not support fault-free system locking, this can lead to surprising things!
if you want to use another database directory for the second server, you can use the
-- datadir = path option of safe_mysqld.
when you want to connect a running, you can use one of the following methods when compiling a MySQL server on the port in the Program of your customer:
�� -- Host 'hostname' -- Port = port_numer or [-- Host localhost] -- socket = file_name
Start the customer.
in your c or Perl program, you can provide port and socket parameters when connecting to the MySQL server.
before you start the customer program, set the mysql_unix_port and mysql_tcp_port environment variables to point to the port of the UNIX socket and TCP/IP. If you usually use a specific socket or port, you should put the command to set these environment variables into your ". login" file.
specify the default socket and TCP/IP Port in the ". My. CNF" file in your home directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.