MySQL 守护进程拒绝以“无法启动服务器:在 TCP/IP 端口上绑定:地址已在使用中”开始(不是)。

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

MySQL daemon refuses to start with "Can't start server: Bind on TCP/IP port: Address already in use" (it's not).

mysqldatabasedaemondedicated-server

提问by Conner Stephen McCabe

Okay guys, I'm ready to bloody give up on this thing, I think I'm almost there though, just one last error, the server starts up fine, but then it fails saying that the bind on TCP/IP port already in use :S Which is not true, as mysql is not running :(

好吧伙计们,我已经准备好放弃这件事了,我想我快到了,只是最后一个错误,服务器启动正常,但随后它失败说 TCP/IP 端口上的绑定已经在使用 :S 这不是真的,因为 mysql 没有运行 :(

Errors:

错误:

bash-4.2$ mysqld
120730 18:31:05 [Note] Plugin 'FEDERATED' is disabled.
120730 18:31:05 InnoDB: The InnoDB memory heap is disabled
120730 18:31:05 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120730 18:31:05 InnoDB: Compressed tables use zlib 1.2.5
120730 18:31:05 InnoDB: Using Linux native AIO
120730 18:31:05 InnoDB: Initializing buffer pool, size = 128.0M
120730 18:31:05 InnoDB: Completed initialization of buffer pool
120730 18:31:06 InnoDB: highest supported file format is Barracuda.
120730 18:31:06  InnoDB: Waiting for the background threads to start
120730 18:31:07 InnoDB: 1.1.8 started; log sequence number 2929794
120730 18:31:07 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
120730 18:31:07 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
120730 18:31:07 [Note] Server socket created on IP: '0.0.0.0'.
120730 18:31:07 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
120730 18:31:07 [ERROR] Do you already have another mysqld server running on port: 3306 ?
120730 18:31:07 [ERROR] Aborting

120730 18:31:07  InnoDB: Starting shutdown...
120730 18:31:08  InnoDB: Shutdown completed; log sequence number 2929794
120730 18:31:08 [Note] mysqld: Shutdown complete

回答by Richard Harrison

Use lsof -i TCP:3306or netstat -lp | grep 3306to find out what is already listening on port 3306 - something must be listening on it.

使用lsof -i TCP:3306netstat -lp | grep 3306找出已经在端口 3306 上侦听的内容 - 必须有某些内容正在侦听它。

You could consider staring the server on a different port (edit my.cnf and change the default port there).

您可以考虑在不同的端口上启动服务器(编辑 my.cnf 并更改那里的默认端口)。

You may need to run this as root, i.e. sudo lsof -i TCP:3306

您可能需要以 root 身份运行它,即 sudo lsof -i TCP:3306