MySQL 无法启动MySql,3306端口忙

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6136389/
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 20:02:37  来源:igfitidea点击:

Can't start MySql, port 3306 busy

mysqlwindowsxampp

提问by Roger

I'm trying to start MySql from XAMPP (under Windows Vista), but it's saying that's port 3306 is busy.

我正在尝试从 XAMPP(在 Windows Vista 下)启动 MySql,但它说端口 3306 很忙。

What would be the best way with check what application is using that port and how to free it?

检查哪个应用程序正在使用该端口以及如何释放它的最佳方法是什么?

Thanks!

谢谢!

采纳答案by Linus Kleen

In a command shell, run:

在命令 shell 中,运行:

netstat -b -p TCP

or

或者

netstat -an | grep -i listen | grep -E 3306

The first command will output a list that you will need to look through for the line that displays localhost:3306in the second column. Below this is the application's name using the port.

第一个命令将输出一个列表,您需要查看localhost:3306第二列中显示的行。下面是使用端口的应用程序名称。

The secondary command will find find the exact port you are looking for and looks something like this:

辅助命令将找到您正在寻找的确切端口,如下所示:

<example-name>:user <example-name>$ netstat -an | grep -i listen | grep -E 3306
tcp46      0      0  *.3306                 *.*                    LISTEN

回答by asas

Just Open task manager and Kill MySql service.

只需打开任务管理器并杀死 MySql 服务。

回答by Prabhat

I had the same problem and was stuck on this thing for a day and I couldn't find a perfect answer anywhere. So I gave it a shot on my own and it worked. This solution is for Windows users. I use Windows 7.

我遇到了同样的问题,在这件事上被困了一天,我在任何地方都找不到完美的答案。所以我自己试了一下,它奏效了。此解决方案适用于 Windows 用户。我使用 Windows 7。

My xampp control panel was displaying an error that port 3306 is busy and in use by some file (name was specified).. say "filename.de".

我的 xampp 控制面板显示错误,端口 3306 正忙且正在被某个文件(名称已指定)使用。说“filename.de”。

Now follow the following steps:

现在按照以下步骤操作:

  1. press Ctrl+Alt+Deland open Task Manager.
  2. Open the "Processes" list and Check for "show all processes" under the list of processes. If you don't see any such option, don't worry! as sometimes administrator permission is required to show some processes.
  3. Now, when you click on "show all processes" button, all the process will be displayed.
  4. Now, switch to "services" tab in the task manager, and a list of services will be displayed. Now look for a service named "filename.de" <-- filename that was diplayed in the error message in xampp.
  5. When you find that service, 'right-click', and then click in option.. GoTo Process.
  6. You will be redirected to the "Processes" tab with focus on a process corresponding to that service. 'Right-Click' and then click on "end process tree".
  7. Now, the issue has been solved! But might have to do the same thing again when you restart your PC. So it is best to keep your PC in sleep-mode.
  8. Otherwise, to solve this issue permanently, open "msconfig" and uncheck that particular process from the services list and click on apply. and you can restart your system.
  1. Ctrl+ Alt+Del并打开任务管理器。
  2. 打开“进程”列表并检查进程列表下的“显示所有进程”。如果您没有看到任何此类选项,请不要担心!因为有时需要管理员权限才能显示某些进程。
  3. 现在,当您单击“显示所有进程”按钮时,将显示所有进程。
  4. 现在,切换到任务管理器中的“服务”选项卡,将显示服务列表。现在查找名为“filename.de”的服务 <-- 在 xampp 的错误消息中显示的文件名。
  5. 当您找到该服务时,“右键单击”,然后单击选项... GoTo Process。
  6. 您将被重定向到“流程”选项卡,重点关注与该服务对应的流程。“右键单击”,然后单击“结束进程树”。
  7. 现在,问题已经解决了!但是当您重新启动 PC 时,可能需要再次执行相同的操作。所以最好让你的电脑处于睡眠模式。
  8. 否则,要永久解决此问题,请打开“msconfig”并从服务列表中取消选中该特定进程,然后单击应用。您可以重新启动系统。

回答by Kashif Iftikhar

As Mentioned By @Segun Emmanuel Run the Following Command:

正如@Segun Emmanuel 所提到的,运行以下命令:

netstat -a -b 

You will get a list of Applications that are using different PORTS. Press Ctrl + Fand write 3306 to find out which Application is using PORT 3306.

您将获得使用不同端口的应用程序列表。按Ctrl + F并写入 3306 以找出哪个应用程序正在使用端口 3306。

enter image description here

在此处输入图片说明

After this, Go to Task Manager via Search Bar or by pressing CTRL + ALT + DEL. Then Under the Background Processes, find out mysqld.exe, right-click on it and you will find an option to close it, namely "End Task".

之后,通过搜索栏或按 转到任务管理器CTRL + ALT + DEL。然后在后台进程下,找到mysqld.exe,右键单击它,您会找到一个关闭它的选项,即“ End Task”。

enter image description here

在此处输入图片说明

Then go to your Xampp Control Paneland start the MySQL service.

然后转到您的Xampp 控制面板并启动 MySQL 服务。

enter image description here

在此处输入图片说明

回答by Mihir Kagrana

In my case it was javaw.exe which was starting on port 3306. This exe does not cause problem if I am logged in using single user in my Windows 10. But if I have multiple logins, it starts this exe for each user and blocks MySQL to start on 3306 port.

就我而言,它是在端口 3306 上启动的 javaw.exe。如果我在 Windows 10 中使用单个用户登录,此 exe 不会导致问题。但如果我有多个登录名,它会为每个用户启动此 exe 并阻止MySQL 在 3306 端口上启动。

Going to task manager and killing this exe for the other user fixed the issue and MySQl could start.

转到任务管理器并为其他用户杀死此 exe 解决了该问题,MySQl 可以启动。

回答by ABODE

If mysql is not starting in xampp, it might be a port conflict issue. Mysql run by default on port 3306. you need to check if another application is occupying that port. use following command to check app occupying a port

如果 mysql 未在 xampp 中启动,则可能是端口冲突问题。Mysql 默认运行在 3306 端口。您需要检查是否有其他应用程序占用了该端口。使用以下命令检查应用程序占用端口

Linux: netstat -tulpn | grep 3306
Window: netstat -a -b 
Mac: lsof -nP -i4TCP:3306

if you find an application occupying that port, stop the application and restart xampp. As an alternative, you can go to php.ini file or click configure in the xampp for mysql and change the mysql port to 3307

如果您发现某个应用程序占用了该端口,请停止该应用程序并重新启动 xampp。或者,您可以转到 php.ini 文件或单击 xampp for mysql 中的配置并将 mysql 端口更改为 3307

回答by naglis mockevicius

Windows icon -> Open cmd.exe.
Type netstat -a -b.
Find what's using it. In my case it was this: Image 1

Windows 图标 -> 打开cmd.exe
键入netstat -a -b
找出正在使用它的内容。在我的情况下是这样的: 图 1

So, I went to task manager. There were no process called so. The I went to servicesand disabled these two:

所以,我去了任务管理器。没有这样的过程。我去了服务并禁用了这两个:

Image 2

图 2

Now everything works fine.

现在一切正常。

回答by AndrewBramwell

I had this problem (slight variation as I was using MAMP)

我遇到了这个问题(在使用 MAMP 时略有不同)

I found this problem was due to having MySQL Workbench installed, MySQL Workbench started the mySQL service on bootup which in turn stopped MAMP being able to use the port.

我发现这个问题是由于安装了 MySQL Workbench,MySQL Workbench 在启动时启动了 mySQL 服务,这反过来又停止了 MAMP 能够使用该端口。

To fix this I had 2 options,

为了解决这个问题,我有 2 个选择,

  1. Uninstall MySQL Workbench
  2. Open Task, click services tab, kill the current MySQL service
  1. 卸载 MySQL 工作台
  2. 打开任务,点击服务选项卡,杀死当前的MySQL服务

This then allowed MAMP to use port 3306

这然后允许 MAMP 使用端口 3306

Hope this may help someone!

希望这可以帮助某人!

回答by rohit kumar ranjan

For this problem, a simpler way on Windows is:-

对于这个问题,在 Windows 上更简单的方法是:-

  1. Go to Task Manager
  2. Go to Services
  3. There will be a services named MySQl80 right click on it and then select "Stop"
  4. Try and start the MySQl module on XAMPP server again
  1. 进入任务管理器
  2. 前往服务
  3. 将有一个名为 MySQl80 的服务右键单击它然后选择“停止”
  4. 再次尝试在 XAMPP 服务器上启动 MySQl 模块