mysql as well as mysqldump (and presumedly all the other tools) silently ignore the --port option if no host is given or it is localhost.
This happens because localhost is treaded specially, and instead a socket connection is made. So the problem here, is that giving --port does not force --protocol=tcp, which would fix this problem.
There are several things that are wrong with this:
a) it is not described with the --port option in the man pages of the respective tools
b) a user input is silently discarded, not even a warning is printed
c) This is really surprising.
d) It is documented somewhere, but not in the obvious places
e) There is already a bug report on this in oracles bug tracker since ages https://bugs.mysql.com/bug.php?id=55796
Well, I'm running out of steam coming up with more letter reasons. But this behavior is really annoying. When would I as the user want to have an explicit `--port` argument be ignored if I give it? I mean, if mysql where able to deduce somehow that the port is going to the same mysql instance as the socket it can find - fine - but I would be very surprised if it could without connecting to both.