Mysql does not connect to a given port if the host is localhost.
If we execute the mysql-client like this
mysql --host=localhost -port=3307 mysql -u root -p --execute="show databases;"
..mysql will ignore the port and will use the unix-domain-socket instead. This is normally a great thing, because TCP-Ports are limited on a machine and can be exhausted on a host with many connections. But what if we explicitly want to connect to Port 3307? The answer is super simple: use 127.0.0.1 instead of the hostname.