Can not connect to MySQL Server by 127.0.0.1

16,550

Solution 1

Maybe the allowed host for root is 'localhost' and your host doesnt map 127.0.0.1<->localhost correctly?

Try setting the host for this user to 127.0.0.1 or % (allow ALL ips to connect)

Solution 2

Have you uncommented the my.cnf's line

skip-networking
Share:
16,550
Hamed Kamrava
Author by

Hamed Kamrava

DevOps enthusiast

Updated on June 09, 2022

Comments

  • Hamed Kamrava
    Hamed Kamrava almost 2 years

    I'm using Ubuntu 12.04 32bit AND MySQL Server 5.5.31

    I can connect to MySQL Server with following command successfully :

    $ mysql -u root -p -h localhost
    

    But when i'm using 127.0.0.1 instead localhost can not connect :

    $ mysql -u root -p -h 127.0.0.1
    

    The error is :

    ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
    

    Any ideas would be awesome.