简体   繁体   English

无法启动MySQL,3306端口忙

[英]Can't start MySQL, port 3306 busy

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?检查哪个应用程序正在使用该端口以及如何释放它的最佳方法是什么?

Just Open task manager and Kill MySql service.只需打开任务管理器并杀死 MySql 服务。

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:3306 in the second column.第一个命令将 output 列出一个列表,您需要在该列表中查找在第二列中显示localhost:3306的行。 Below this is the application's name using the port.下面是使用端口的应用程序名称。

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

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.此解决方案适用于 Windows 用户。 I use Windows 7.我使用 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 + Del and open Task Manager.Ctrl + Alt + Del并打开任务管理器。
  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.现在查找名为“filename.de”的服务<--在 xampp 的错误消息中显示的文件名。
  5. When you find that service, 'right-click', and then click in option.. GoTo Process.当您找到该服务时,“右键单击”,然后单击选项.. 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.但是当您重新启动 PC 时,可能必须再次执行相同的操作。 So it is best to keep your PC in sleep-mode.因此,最好让您的 PC 处于睡眠模式。
  8. Otherwise, to solve this issue permanently, open "msconfig" and uncheck that particular process from the services list and click on apply.否则,要永久解决此问题,请打开“msconfig”并从服务列表中取消选中该特定进程,然后单击应用。 and you can restart your system.您可以重新启动系统。

If mysql is not starting in xampp, it might be a port conflict issue.如果 mysql 未在 xampp 中启动,则可能是端口冲突问题。 Mysql run by default on port 3306. you need to check if another application is occupying that port. Mysql 默认在 3306 端口上运行。您需要检查是否有其他应用程序占用了该端口。 use following command to check app occupying a port使用以下命令检查应用程序占用端口

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.如果您发现某个应用程序占用了该端口,请停止该应用程序并重新启动 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 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

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 可以启动。

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 + F and write 3306 to find out which Application is using PORT 3306.Ctrl + F并写入 3306 以找出哪个应用程序正在使用 PORT 3306。

在此处输入图像描述

After this, Go to Task Manager via Search Bar or by pressing CTRL + ALT + DEL .在此之后,Go 通过搜索栏或按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 ".然后在后台进程下,找到mysqld.exe ,右键单击它,你会找到一个关闭它的选项,即“ End Task ”。

在此处输入图像描述

Then go to your Xampp Control Panel and start the MySQL service.然后 go 到您的Xampp 控制面板并启动 MySQL 服务。

在此处输入图像描述

Windows icon -> Open cmd.exe . Windows 图标 -> 打开cmd.exe
Type netstat -a -b .键入netstat -a -b
Find what's using it.找出什么在使用它。 In my case it was this:在我的情况下是这样的: 图 1

So, I went to task manager .所以,我去了任务管理器 There were no process called so.没有这样的过程。 The I went to services and disabled these two:我去服务并禁用了这两个:

图 2

Now everything works fine.现在一切正常。

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,为了解决这个问题,我有两个选择,

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

This then allowed MAMP to use port 3306然后这允许 MAMP 使用端口 3306

I've been having trouble for hours on this error.我在这个错误上遇到了几个小时的麻烦。 I was trying to run MySQL from XAMPP after quite some time.一段时间后,我试图从 XAMPP 运行 MySQL 。 It gave errors, similar to yours, it said that port 3306 is in use.它给出了错误,类似于您的错误,它说端口 3306 正在使用中。 If you:如果你:

  • are running on Windows 10在 Windows 10 上运行
  • are avoiding to change the port number of MySQL from 3306正在避免将 MySQL 的端口号从 3306 更改
  • can't see any program using the 3306 port from netstatnetstat看不到任何使用 3306 端口的程序
  • reinstalling and deleting everything yet it still give the same error重新安装并删除所有内容但它仍然给出相同的错误
  • are enabling and using Hyper-V正在启用和使用 Hyper-V
  • all of the other solutions didn't work所有其他解决方案均无效

This is the solution that worked for me:这是对我有用的解决方案:

  • Go to the most right of the taskbar and right-click the connection icon, click Open Network & Internet settings Go 在任务栏的最右侧并右键单击连接图标,单击Open Network & Internet settings
  • Click Change adapter options单击Change adapter options
  • Right-click and Disable everything that relates to Hyper-V右键单击并禁用与 Hyper-V 相关的所有内容

I ran MySQL again at now it works.我再次运行 MySQL 现在它可以工作了。

This command kills the existing mysql process and perhaps one can start it afresh此命令会终止现有的 mysql 进程,也许可以重新启动它

sudo pkill mysql

It has helped me solve this challenge most of times大多数时候它帮助我解决了这个挑战

1. Turn off the application which is using this port, open terminal and run "lsof -n -P -i | grep 3306" to figure out.
2. Use different ports, right click on the server -> Edit.

For this problem, a simpler way on Windows is:-对于这个问题,Windows 上更简单的方法是:-

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

If you where not able to find any application or process listening on port 3306 , you might need to check your network adapters .如果您无法找到任何应用程序或进程正在侦听端口3306 ,您可能需要检查您的网络适配器

  • Disable adapters you do not use.禁用不使用的适配器。

  • Pay also attention to the Hyper-V generated network adapter, disable it if you don't need it.还要注意Hyper-V生成的网络适配器,如果不需要,请禁用它。 Sometimes it can reserve some ports and commands like netstat will not be able to find it out有时它可以保留一些端口, netstat之类的命令将无法找到它

This error occurs if you have installed mysql two times.如果您安装了两次 mysql,则会出现此错误。 mysql by default uses the port 3306. If you have installed it twice then already there is a mysql at your port number 3306. So you will have to change your port. mysql 默认使用端口 3306。如果您安装了两次,那么在您的端口号 3306 处已经有一个 mysql。所以您必须更改您的端口。

If you are using xampp then you can easily change your port.如果您使用的是 xampp,那么您可以轻松更改您的端口。 Steps to change port: Step 1: Open your xampp as administrator.更改端口的步骤: 步骤 1:以管理员身份打开您的 xampp。 Step 2: Click on 'Config' at the top right corner of your xampp.第 2 步:单击 xampp 右上角的“配置”。 Step 3: Click on 'Service and Port Settings' and after that change the main port of mysql from 3306 to 3307 and the click on save.第 3 步:点击“服务和端口设置”,然后将 mysql 的主端口从 3306 更改为 3307,然后点击保存。 Step 4: Then click on 'config' which is in front of mysql and open 'my.ini' file which will be a text file.第4步:然后点击mysql前面的'config',打开'my.ini'文件,这将是一个文本文件。 Step 5: Now wherever in the text file you see the port number mentioned as 3306 change it to 3307 and then save the file.第 5 步:现在在文本文件中的任何位置,您都会看到提到的端口号为 3306,将其更改为 3307,然后保存文件。

After doing this again start your mysql server and it will start running on port 3307.再次执行此操作后,启动您的 mysql 服务器,它将开始在端口 3307 上运行。

This worked for me and I hope it will work for anyone else who encounters the same issue.这对我有用,我希望它对遇到同样问题的其他人也有用。

Okay so none of the solutions provided here and many sites works in my case and so I realize DBrowser for SQLite was the cause for mysql not starting so I just uninstalled it and that's.好的,所以这里提供的解决方案和许多网站都不适用于我的情况,所以我意识到 SQLite 的 DBrowser 是导致 mysql 无法启动的原因,所以我只是卸载了它,就是这样。 Hey but you can find a way a to stop than uninstall it.嘿,但你可以找到一种方法来停止而不是卸载它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM