今天一同事说他的mysql数据库起不来了,很是郁闷,报错如下

# /etc/init.d/mysql start

Starting MySQL.... ERROR! The server quit without updating PID file (/data/mysql/mysql3306/data/mysql.pid).


我第一时间想到要看错误日志,错误日志如下:

# vim error.log 

2017-05-04T13:35:17.965606Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Permission denied

2017-05-04T13:35:17.965643Z 0 [ERROR] Do you already have another mysqld server running on port: 1005 ?

2017-05-04T13:35:17.965674Z 0 [ERROR] Aborting


(1)首先第一反应是权限不足,通过排查,用户权限足够,mysql数据目录所有者和所属组都是mysql,故排除;

(2)报错第二句表明可能存在mysql服务占用1005端口,于是通过ss -nltup|grep mysql命令查看结果是并没有任何mysql服务。

(3)最后上网百度了很多,都无果,突然有个想法,mysql的端口范围包含1005吗?于是查看手册发现如下:

--port=port_num

The port number that the server should use when listening for TCP/IP connections. The port number

must be 1024 or higher unless the server is started by the root system user.

手册写的很是清楚,mysql的port范围是大于等于1024,费了那么长的时间,才发现原来人家手册早就写死了,真实吃力不讨好,还是老老实实用默认端口,多多阅读手册吧。