On one machine, how to start two mysql services? How
to run two mysql services on one machine, corresponding to two databases? What should I do?
Best answer
Jul 26 10:36 There are situations where you may want to run multiple servers on the same machine. For example, you may want to test a new MySQL version without disturbing your existing production system setup, or you may be an Internet service provider who wants to provide independent MySQL installations for different customers.
If you want to run multiple servers, the easiest way is to recompile the servers with different TCP/IP ports and socket files, so they are not listening on the same TCP/IP port or socket.
Assuming an existing server is configured with a default port number and socket file, then set up the new server with a configure command line like this:
shell> ./configure --with-tcp-port=port_number
--with-unix-socket=file_name
--prefix=/usr/local/mysql-3.22.9
where port_number and file_name should be different from the default port number and socket file pathname, and the --prefix value should specify a different installation than the existing MySQL installation. Table of contents.
You can check the socket and port used by any currently executing MySQL with this command:
shell> mysqladmin -h hostname --port=port_number variables
If you have a MySQL server running on the port you are using, you You will get a table of some of MySQL's most important configurable variables, including socket names, etc.
You should also edit your machine's init script (probably "mysql.server") to start and kill multiple mysqld servers.
You don't have to recompile a new MySQL server, just start it with a different port and socket. You can change the port and socket by specifying the options used by safe_mysqld when running:
shell> /path/to/safe_mysqld --socket=file_name --port=port_number
if you are on the same server as another that has logging enabled When running a new server in the database directory, you should also specify the name of the log file using the --log and --log-update options of safe_mysqld, otherwise, both servers may be trying to write to the same log file.
Warning: Normally you should never have 2 servers updating data in the same database! If your OS does not support fault-free system locking, this can cause surprising things to happen!
If you want to use another database directory for the second server, you can use the --datadir=path option of safe_mysqld.
good
50% (0) Bad
50% (0)