There are two ways to connect to a MySQL server.
First use a UNIX socket, for example /tmp/mysql.sock , and in this case there is no "host", so username@localhost is used for authentication. This will only work when connected from the same machine.
Secondly, using a TCP / IP connection. In this case, the server listens for a specific port in the box working with the database, and the way to connect to it is to provide the host number + port. The port number can be optional (used by default), and the host can be specified by the host name or by ip-address. This allows you to connect locally or remotely.
Note. I have no way to verify this (no access to your server), so below is just a possible explanation ...
In mysql -u knowitdbadmin -p -h192.168.0.50 host (-h) is set, therefore, the TCP / IP protocol is used, as a result of which authentication uses the username@hostname or username@ % rules, but this will not use username@localhost .
No host (-h) is specified in mysql -u knowitdbadmin -p , so the default UNIX socket is used, forcing authentication to use username@localhost (and therefore fails).
If you want to disable access using the UNIX socket (/tmp/mysql.sock) and the @localhost username and always use the TCP / IP connection, follow all the steps: * delete grants for the @localhost username (done) * always specify the host / IP (+ port) in the configuration files from your application.
I think the problem is related to:
socket: /tmp/mysql.sock
try using the host number + port number instead.
As a side note, if you somehow have SQL access to the database itself starting from 5.5, the new performance_schema.host_cache table will show you all the reasons for the connection to fail, which saves a lot of time when troubleshooting it.