mysql| Server
third, stop the server
To start the server manually, use Mysqladmin:
%mysqladmin shutdown
To stop the server automatically, you don't need to do anything special. BSD systems typically stop the service by sending a term signal to the process, either answering it correctly or being rudely killed. MYSQLD when it receives this signal to terminate as an answer. For System V-style systems that start the server with Mysql.server, the stop process will invoke the script with a stop parameter, telling the server to terminate, assuming that you have installed the Mysql.server.
If you can't connect to the server, how to regain control of the server
In some cases, you may be able to manually reboot the server because you cannot connect to it. Of course, this is a bit contradictory. Because you typically turn it off by connecting to the server, how does this happen?
First, the MySQL root password can be set to a value you don't know, which can happen when you change the password, for example, if you accidentally type an invisible control character when you enter a new password. You may also forget your password.
Second, the connection localhost is usually done through a UNIX domain socket file, typically/tmp/mysql.sock. If the socket file is deleted, the local client cannot connect. This can happen when your system runs a cron task that deletes the temp file under/tmp.
If you can't connect because you lost your socket file, you can simply recreate it by restarting the server. Because the server recreated it at startup. The scam here is that you can't create a connection with a socket because it's gone, you have to establish a TCP/IP connection, for example, if the server host is pit.snake.net, you can connect this way:
%mysqladmin-p-u root-h pit.snake.net shutdown
If the socket file is deleted by a cron task, the problem will recur unless you modify the cron task or use one or a different socket file, you can use the Global option file to specify a different socket, for example, if the data directory is/usr/local/var, You can move the socket file there by adding the following line to the/ETC/MY.CNF:
[Mysqld]
Socket=/usr/local/var/mysql.sock
[Client]
Socket=/usr/local/var/mysql.sock
Specify the pathname for both the server and the customer so that they all use the same socket file. If you only set the path for the server, the client will still expect to execute the socket in the original location, reboot the server after the modification, and make it create a socket in the new location.
If you cannot connect because you have forgotten the root password or have set it to a different value than you think, you need to regain control of the server, and you can set the password again:
Interrupt Server
If you log on to the server host with root, you can terminate the server with the KILL command. You can use the PS command or search the server's PID file (usually in the data directory) to find the server process ID.
It is best to first try a normal kill that sends a term signal to the server to see if it will respond with a normal termination. In this way, the tables and logs will be emptied correctly. If the server is blocked and does not answer a normal termination signal, you can force it to terminate with kill-9. This is the last resort, because there may be an empty modification, and you risk keeping the table in an inconsistent state.
If you terminate the server with Kill-9, be sure to check your table with Myisamchk and ISAMCHK before starting the server.
Restart the server with the--skip-grant-table option.
This tells the server not to use the authorization table to authenticate the connection, which allows you to connect as root without requiring a password. After you have connected, change the root password.
Use Mysqladmin flush-privileges to tell the server to start using the authorization table again
If your mysqladmin version doesn't know Flash-privileges, try reload.
Five, running multiple servers
Most can run a single MySQL server on a given machine, but in many cases it is useful to run multiple servers:
You may want to test a new version of a server and keep the production server you are running. In this case, you will run different server code.
The operating system generally restricts the number of open file handles per process. If your system is difficult to increase this limit, running multiple servers is one way to resolve the restrictions. In this case, you might run multiple instances of the consolidated server.
ISPs often provide their customers with their own MySQL installation, and it is necessary to involve a separate server. In this case, you may run multiple instances of the same version or different versions if different customers want different versions of MySQL.
Naturally, running multiple servers is much more complicated than running only one server. If you install multiple versions, you cannot install everything in the same place. When the server is running, some parameters must or are likely to be unique to each server, including where the server is installed, the path name of its data directory, the TCP/IP port and the UNIX domain socket pathname, and the UNIX account used to run the server (if you are no longer running all servers under the same account). If you decide to run multiple servers, be sure to pay attention to the parameters you use, and you are not.