Cannot connect from elsewhere than a console
Probably mysql doesn't listen the TCP sockets at all and console client is connected via filesocket. Try to list all network sockets listened at your host: 

ss -l | grep 3306


The other possibility is that you have turned skip_name_resolve variable ON that disable using of localhost instead of 127.0.0.1.