How to stop mysql server
How to stop mysql server
How to stop mysql server
To start and stop MySQL automatically on your server, you must add start and stop commands to the appropriate places in your /etc/rc* files:
After installing the script, the commands needed to activate it to run at system startup depend on your operating system. On Linux, you can use chkconfig :
On some Linux systems, the following command also seems to be necessary to fully enable the mysql script:
As an alternative to the preceding setup, some operating systems also use /etc/rc.local or /etc/init.d/boot.local to start additional services on startup. To start up MySQL using this method, append a command like the one following to the appropriate startup file:
For other systems, consult your operating system documentation to see how to install startup scripts.
Table 4.2 mysql.server Option-File Options
Option Name | Description | Type |
---|---|---|
basedir | Path to MySQL installation directory | Directory name |
datadir | Path to MySQL data directory | Directory name |
pid-file | File in which server should write its process ID | File name |
service-startup-timeout | How long to wait for server startup | Integer |
The path to the MySQL installation directory.
The path to the MySQL data directory.
The path name of the file in which the server should write its process ID. The server creates the file in the data directory unless an absolute path name is given to specify a different directory.
How to stop mysql server
This section discusses methods for starting and stopping the MySQL server.
Generally, you start the mysqld server in one of these ways:
Invoke mysqld directly. This works on any platform.
On Windows, you can set up a MySQL service that runs automatically when Windows starts. See Section 5.4.7, “Starting MySQL as a Windows Service”.
On Solaris, use the service management framework (SMF) system to initiate and control MySQL startup.
The mysqld_safe and mysql.server scripts, Solaris SMF, and the macOS Startup Item (or MySQL Preference Pane) can be used to start the server manually, or automatically at system startup time. mysql.server and the Startup Item also can be used to stop the server.
The following table shows which option groups the server and startup scripts read from option files.
Table 9.1 MySQL Startup Scripts and Supported Server Option Groups
[mysqld- major_version ] means that groups with names like [mysqld-5.5] and [mysqld-5.6] are read by servers having versions 5.5.x, 5.6.x, and so forth. This feature can be used to specify options that can be read only by servers within a given release series.
For backward compatibility, mysql.server also reads the [mysql_server] group and mysqld_safe also reads the [safe_mysqld] group. However, you should update your option files to use the [mysql.server] and [mysqld_safe] groups instead.
For more information on MySQL configuration files and their structure and contents, see Using Option Files.
Chapter 3 The Server Shutdown Process
The server shutdown process takes place as follows:
The shutdown process is initiated.
This can occur initiated several ways. For example, a user with the SHUTDOWN privilege can execute a mysqladmin shutdown command. mysqladmin can be used on any platform supported by MySQL. Other operating system-specific shutdown initiation methods are possible as well: The server shuts down on Unix when it receives a SIGTERM signal. A server running as a service on Windows shuts down when the services manager tells it to.
The server creates a shutdown thread if necessary.
Depending on how shutdown was initiated, the server might create a thread to handle the shutdown process. If shutdown was requested by a client, a shutdown thread is created. If shutdown is the result of receiving a SIGTERM signal, the signal thread might handle shutdown itself, or it might create a separate thread to do so. If the server tries to create a shutdown thread and cannot (for example, if memory is exhausted), it issues a diagnostic message that appears in the error log:
The server stops accepting new connections.
To prevent new activity from being initiated during shutdown, the server stops accepting new client connections by closing the handlers for the network interfaces to which it normally listens for connections: the TCP/IP port, the Unix socket file, the Windows named pipe, and shared memory on Windows.
The server terminates current activity.
For each thread associated with a client connection, the server breaks the connection to the client and marks the thread as killed. Threads die when they notice that they are so marked. Threads for idle connections die quickly. Threads that currently are processing statements check their state periodically and take longer to die. For additional information about thread termination, see KILL Statement, in particular for the instructions about killed REPAIR TABLE or OPTIMIZE TABLE operations on MyISAM tables.
For threads that have an open transaction, the transaction is rolled back. If a thread is updating a nontransactional table, an operation such as a multiple-row UPDATE or INSERT may leave the table partially updated because the operation can terminate before completion.
If the server is a replication source server, it treats threads associated with currently connected replicas like other client threads. That is, each one is marked as killed and exits when it next checks its state.
If the server is a replica server, it stops the replication I/O and SQL threads, if they are active, before marking client threads as killed. The SQL thread is permitted to finish its current statement (to avoid causing replication problems), and then stops. If the SQL thread is in the middle of a transaction at this point, the server waits until the current replication event group (if any) has finished executing, or until the user issues a KILL QUERY or KILL CONNECTION statement. See also STOP SLAVE Statement. Since nontransactional statements cannot be rolled back, in order to guarantee crash-safe replication, only transactional tables should be used.
The server shuts down or closes storage engines.
At this stage, the server flushes the table cache and closes all open tables.
Each storage engine performs any actions necessary for tables that it manages. InnoDB flushes its buffer pool to disk (unless innodb_fast_shutdown is 2), writes the current LSN to the tablespace, and terminates its own internal threads. MyISAM flushes any pending index writes for a table.
The server exits.
To provide information to management processes, the server returns one of the exit codes described in the following list. The phrase in parentheses indicates the action taken by systemd in response to the code, for platforms on which systemd is used to manage the server.
0 = successful termination (no restart done)
1 = unsuccessful termination (no restart done)
2 = unsuccessful termination (restart done)
Stop MySQL service windows
I am developing a website and need to refresh data. Therefore MySQL must be stopped.
How can I stop the service?
When I look at control panel services it is started without stop or restart option.
17 Answers 17
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
On Windows
If you are using Windows Open the Command Prompt and type
To Stop MySQL Service:
To Start MySQL Service:
On Linux
Fedora / Red Hat also support this:
Also Systemd based distrubutions (like Ubuntu or Arch Linux) support this:
I know this answer is late but i hope it helps for some one.
You can set its startup type to manual in services.msc. This way it will not start automatically unless required. Simply get the name of the service from services.msc as shown here:
You can create batch files to start and stop the service fairly easily as well. Now use this name in batch files.
And in your stop.bat:
The Top Voted Answer is out of date. I just installed MySQL 5.7 and the service name is now MySQL57 so the new command is
net stop MySQL57
Start Powershell as administrator and run:
Find the service name:
run ‘services.msc’, look for MySQL and click on properties
For Windows there’s a couple of tricks to take care of.
(Assuming you’ve installed MySQL from Oracle’s site but maybe have chosen not to run the service at startup).
Now that you have local OS admin access you can use «mysqld stop» (which will simply return)
IF YOU SEE THE FOLLOWING YOU ARE TRYING IT WITH A USER/COMMAND PROMPT THAT DOES NOT HAVE THE CORRECT PRIVILEGES:
If mysqld does not appear as a known system command, try adding it to your class path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\MySQL\MySQL Server 5.5\bin
How to stop mysqld
To find out the start command for mysqld (using a mac) I can do:
I get the following output, which allows me to start mysql server.
How would I find the necessary command to stop mysql from the command line?
21 Answers 21
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
If you install the Launchctl in OSX you can try:
MacPorts
Note: this is persistent after reboot.
Homebrew
Binary installer
There is an alternative way of just killing the daemon process by calling
I did it with next command:
For Windows, you can run this command directly if mysql/bin is in your path.
Worked for me on mac
a) Stop the process
If the result shows anything like: «xxx.xxx.mysqlxxx»
Example: sudo launchctl remove org.macports.mysql56-server
b) Disable to autostart the process
Note: In some cases if you tried «a)» first, you need to reboot again before try b).