停止 MySQL 服务窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10885038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:39:24  来源:igfitidea点击:

Stop MySQL service windows

mysqlshutdownrestart

提问by jop

I am developing a website and need to refresh data. Therefore MySQL must be stopped.
How can I stop the service?

我正在开发一个网站,需要刷新数据。因此必须停止 MySQL。
如何停止服务?

When I look at control panel services it is started without stop or restart option.

当我查看控制面板服务时,它是在没有停止或重新启动选项的情况下启动的。

回答by vinothp

On Windows

在 Windows 上

If you are using windows Open the Command Prompt and type

如果您使用的是 Windows 打开命令提示符并键入

To Stop MySQL Service

停止 MySQL 服务

net stop MySQL 

To Start MySQL Service

启动 MySQL 服务

net start MySQL.

On Linux

在 Linux 上

Expand|Select|Wrap|Line Numbers

展开|选择|换行|行号

# /etc/init.d/mysqld start
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld restart

Fedora / Red Hat also support this:

Fedora / Red Hat 也支持这个:

 Expand|Select|Wrap|Line Numbers
 # service mysqld start
 # service mysqld stop
 # service mysqld restart

I know this answer is late but i hope it helps for some one.

我知道这个答案来晚了,但我希望它对某些人有所帮助。

回答by Nishu Tayal

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:

您可以在 services.msc 中将其启动类型设置为手动。这样它就不会自动启动,除非需要。只需从 services.msc 获取服务名称,如下所示:

enter image description here

在此处输入图片说明

You can create batch files to start and stop the service fairly easily as well. Now use this name in batch files.

您也可以创建批处理文件以相当轻松地启动和停止服务。现在在批处理文件中使用此名称。

Your start.bat:

你的start.bat:

net start "mysql"

And in your stop.bat:

在你的 stop.bat 中:

net stop "mysql"

回答by Matthew Verstraete

The Top Voted Answer is out of date. I just installed MySQL 5.7 and the service name is now MySQL57so the new command is

最高投票的答案已过时。我刚刚安装了 MySQL 5.7,服务名称现在是,MySQL57所以新命令是

net stop MySQL57

net stop MySQL57

回答by Bar Horing

Start Powershell as administrator and run:

以管理员身份启动 Powershell 并运行:

net start [MySQL-service-name]

Find the service name:

查找服务名称:

run 'services.msc', look for MySQL and click on properties

运行“services.msc”,查找 MySQL 并单击属性

enter image description here

在此处输入图片说明

回答by foupfeiffer

For Windows there's a couple of tricks to take care of...

对于 Windows,有几个技巧需要注意......

(Assuming you've installed MySQL from Oracle's site but maybe have chosen not to run the service at startup)...

(假设您已经从 Oracle 的站点安装了 MySQL,但可能选择不在启动时运行该服务)...

  1. To use "mysqld stop" from the command line for WinVista/Win7 you must right click on Start -> All Programs -> Accessories -> Command Prompt -> Run As Administrator

  2. Now that you have local OS admin access you can use "mysqld stop" (which will simply return)

  1. 要在 WinVista/Win7 的命令行中使用“mysqld stop”,您必须右键单击开始 -> 所有程序 -> 附件 -> 命令提示符 -> 以管理员身份运行

  2. 现在您拥有本地操作系统管理员访问权限,您可以使用“mysqld stop”(它将简单地返回)

IF YOU SEE THE FOLLOWING YOU ARE TRYING IT WITH A USER/COMMAND PROMPT THAT DOES NOT HAVE THE CORRECT PRIVILEGES:

如果您看到以下内容,您正在尝试使用没有正确权限的用户/命令提示:

121228 11:54:50 [Warning] Can't create test file c:\Program Files\MySQL\MySQL Server 5.5\data\hpdv7.lower-test
121228 11:54:50 [Warning] Can't create test file c:\Program Files\MySQL\MySQL Server 5.5\data\hpdv7.lower-test
121228 11:54:50 [Note] Plugin 'FEDERATED' is disabled.
121228 11:54:50 InnoDB: The InnoDB memory heap is disabled
121228 11:54:50 InnoDB: Mutexes and rw_locks use Windows interlocked functions
121228 11:54:50 InnoDB: Compressed tables use zlib 1.2.3
121228 11:54:50 InnoDB: Initializing buffer pool, size = 128.0M
121228 11:54:50 InnoDB: Completed initialization of buffer pool
121228 11:54:50  InnoDB: Operating system error number 5 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory. It may also be you have created a subdirectory
InnoDB: of the same name as a data file.
InnoDB: File name .\ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.

If mysqld does not appear as a known system command, try adding it to your class path

如果 mysqld 没有作为已知的系统命令出现,请尝试将其添加到您的类路径中

  1. Right click on My Computer
  2. Advanced System Settings
  3. Environment Variables
  4. System variables
  5. look for and left click select the variable named path
  6. click on "Edit" and copy out the string to notepad and append at the end the full path to your MySQL bin directory , e.g.

    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\MySQL\MySQL Server 5.5\bin

  1. 右键单击我的电脑
  2. 高级系统设置
  3. 环境变量
  4. 系统变量
  5. 查找并左键单击选择名为 path 的变量
  6. 单击“编辑”并将字符串复制到记事本并在末尾附加到 MySQL bin 目录的完整路径,例如

    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\MySQL\MySQL Server 5.5\bin

回答by Sebas

net stop MySQL*

or

或者

mysqld stop

or

或者

mysql stop

in the window's command line prompt.

在窗口的命令行提示符中。

<*> if you're using windows XP, you need the name of your service, which can be obtained doing this: (credits @Atli)

<*> 如果您使用的是 Windows XP,则需要您的服务名称,可以通过以下方式获得:(感谢@Atli

right click the "My Computer" shortcut in the Start menu, select "Manage", click "Services" in the "Services and applications" group. And then search the list of services until you find the MySQL service.

Then you can start [or stop] the service by using that name. It is can sometimes be called "mysql5" or "mysql51", or something like that. Depends on who installed it.

右键单击开始菜单中的“我的电脑”快捷方式,选择“管理”,单击“服务和应用程序”组中的“服务”。然后搜索服务列表,直到找到 MySQL 服务。

然后您可以使用该名称启动 [或停止] 服务。它有时可以称为“mysql5”或“mysql51”,或类似的名称。取决于谁安装了它。

回答by Green

I'm on XP. I've installed MySQL-5.6.10 manually from .zip, no Windows auto-installer provided by MySQL site. The /bindirectory of my MySQL is in my PATH. So I start the server with mysqld --consolecommand, like this:

我在 XP 上。我已经从 手动安装了 MySQL-5.6.10 .zip,MySQL 站点没有提供 Windows 自动安装程序。在/bin我的MySQL的目录是在我的道路。所以我用mysqld --console命令启动服务器,如下所示:

C:\Documents and Settings\User>mysqld --console
2013-04-12 14:39:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_times
tamp server option (see documentation for more details).

From now on it is running. And that cmd window is occupied. I open and use another one.

从现在开始它正在运行。那个 cmd 窗口被占用了。我打开并使用另一个。

I've tried to use the answers from above but none of them can stop the server. Only errors are throw. So I stop the server with mysqladmin -u root shutdownon the other cmd window or with Ctrl + Con the cmd window it is running in. The latter works not so good as the former, sometimes I have to click Ctrl + Ctwice or more.

我尝试使用上面的答案,但没有一个可以停止服务器。只抛出错误。所以我mysqladmin -u root shutdown在另一个 cmd 窗口或Ctrl + C在它运行的 cmd 窗口上停止服务器。后者的效果不如前者,有时我必须单击Ctrl + C两次或更多次。

The log of the shutdown process is like this:

关机过程的日志是这样的:

2013-04-12 17:55:29 3968 [Note] Giving 0 client threads a chance to die gracefully
2013-04-12 17:55:29 3968 [Note] Event Scheduler: Purging the queue. 0 events
2013-04-12 17:55:29 3968 [Note] Shutting down slave threads
2013-04-12 17:55:29 3968 [Note] Forcefully disconnecting 0 remaining clients
2013-04-12 17:55:29 3968 [Note] Binlog end
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'partition'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_FT_INSERTED'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_METRICS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_CMPMEM'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_CMP'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_LOCKS'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'INNODB_TRX'
2013-04-12 17:55:29 3968 [Note] Shutting down plugin 'InnoDB'
2013-04-12 17:55:29 3968 [Note] InnoDB: FTS optimize thread exiting.
2013-04-12 17:55:29 3968 [Note] InnoDB: Starting shutdown...
2013-04-12 17:55:30 3968 [Note] InnoDB: Shutdown completed; log sequence number 1719777
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'BLACKHOLE'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'ARCHIVE'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'MRG_MYISAM'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'MyISAM'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'MEMORY'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'CSV'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'sha256_password'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'mysql_old_password'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'mysql_native_password'
2013-04-12 17:55:30 3968 [Note] Shutting down plugin 'binlog'
2013-04-12 17:55:30 3968 [Note] mysqld: Shutdown complete

And I still don't know if it is 100% right way to shutdown the server, but it works :)

而且我仍然不知道关闭服务器是否是 100% 正确的方法,但它有效:)

回答by Vitalie

If MySQL 57.

如果 MySQL 57.

net start MySQL57

OR

或者

net stop MySQL57

回答by Yar

to stop the service:

停止服务:

sc stop mysql56

sc stop mysql56

and to start it:

并启动它:

sc start mysql56

sc start mysql56

you might need to change the mysql56to whatever your version is.

您可能需要将 更改mysql56为您的版本。

回答by NrgwenyaDev

Easy way to shutdown mySQL server for Windows7 :

关闭 Windows7 的 mySQL 服务器的简单方法:

My Computer > Manage > Services and Application > Services > select "MySQL 56"(the name depends upon the version of MySQL installed.) three options are present at left top corner. Stop the Service pause the Service Restart the Service

我的电脑 > 管理 > 服务和应用程序 > 服务 > 选择“MySQL 56”(名称取决于安装的 MySQL 版本。)左上角有三个选项。停止服务 暂停服务 重启服务

choose Stop the service > to stop the server

选择停止服务 > 停止服务器

Again to start you can come to the same location or we can chose tools options on mySQL GUI Server > Startup/Shutdown > Choose to Startup or Shutdown

再次开始,您可以来到相同的位置,或者我们可以在 mySQL GUI Server > 启动/关闭 > 选择启动或关闭上选择工具选项

PS: some times it is not possible to stop the server from the GUI even though the options are provided. so is the reason the above alternative method is provided.

PS:有时即使提供了选项,也无法从 GUI 停止服务器。提供上述替代方法的原因也是如此。

share the ans. to improve. thanks

分享答案。改进。谢谢