Bug #102080 MySQL ports in the 33060 - 33069 range may overlap with local port range
Submitted: 29 Dec 2020 7:44 Modified: 11 Jan 2021 16:09
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:8.0.22 OS:Any
Assigned to: CPU Architecture:Any

[29 Dec 2020 7:44] Daniël van Eeden
Description:
MySQL uses ports in the 33060 - 33069 range for various things (X Protocol, Admin Port, etc). 

However with the default settings of `ip_local_port_range` and `ip_local_reserved_ports` some of these ports may be chosen as local port for TCP connections by other applications. The result is that MySQL can't bind to the admin port (if configured) and will refuse to start.

2020-12-28T21:14:53.393253Z 0 [Note] [MY-010252] [Server] Server hostname (bind-address): 'myserver.example.com'; port: 33062
2020-12-28T21:14:53.394106Z 0 [Note] [MY-010264] [Server]   - 'myserver.example.com' resolves to '10.0.0.1';
2020-12-28T21:14:53.400054Z 0 [Note] [MY-010251] [Server] Server socket created on IP: '10.0.0.1'.
2020-12-28T21:14:53.400355Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use
2020-12-28T21:14:53.400577Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 33062 ?
2020-12-28T21:14:53.401266Z 0 [ERROR] [MY-010119] [Server] Aborting

https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt

How to repeat:
See description

Suggested fix:
Update docs to configure `ip_local_port_range` and `ip_local_reserved_ports` to avoid this.

Maybe also have the installation take care of this if possible. For example by adding files to sysctl.d(5)
https://man7.org/linux/man-pages/man5/sysctl.d.5.html

Consider adding info about this to the error messages.
[29 Dec 2020 8:00] MySQL Verification Team
Hello Daniël,

Thank you for the report and feedback.

regards,
Umesh
[29 Dec 2020 8:17] Daniël van Eeden
It would also be helpful to print the pid and process name of the process that is using that port if that info is available.
[11 Jan 2021 16:09] Daniel Price
Posted by developer:
 
The MySQL Port Reference has been updated. Changes will appear online soon.
https://dev.mysql.com/doc/mysql-port-reference/en/mysql-ports-introduction.html

Thank you for the bug report.