Mysql – Cannot connect from elsewhere than a console

connectivitylinuxmariadbMySQL

I am quite a beginner with MySQL, but I already got problems with setting up a connection. I tried to use MySQL Workbench, but I can't connect to the server. I use SparkyLinux, a Debian-based distribution. Here is what I did so far :

  1. I created a user and checked that I could log in a console :

    adrien@sahelantropus:~$ mysql -u adrien -p
    
    Enter password: 
    
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 6
    Server version: 10.1.23-MariaDB-9+deb9u1 Debian 9.0
    
    Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input 
    statement.
    
    MariaDB [(none)]>

    (maybe it is interesting to notice I can either give my password or not, and log in with exactly the same output)

  2. I tried to setup a connection with MySQL Workbench, but when I test it, I get the following output :

    Failed to Connect to MySQL at 127.0.0.1:3306 with user adrien
    Access denied for user 'adrien'@'localhost'

  3. I tried to use MySQL Connector in Python, and got the following exception :

    1698 (28000): Access denied for user 'adrien'@'localhost'

I am sorry if something obvious is going on and I cannot see it, and I thank anyone who could help me.

Best Answer

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.