FUN WITH LINUX

Mysql does not connect to a given port on localhost

7 December 2016

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.

[ Linux  Sysadmin  Tricks  Database  ]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 Unported License.

Copyright 2015-present Hoti