Home  >  Q&A  >  body text

Troubleshooting: Error 111 - Unable to connect to MySQL server

<p>I installed the MySQL server on a Linux host with the IP address 192.168.1.100, but when I try to connect to this IP, I always get an error (111). But using localhost and 127.0.0.1 is ok. </p> <pre>beer@beer-laptop# ifconfig | grep "inet addr" inet addr:127.0.0.1 Mask:255.0.0.0 inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0 beer@beer-laptop# mysql -ubeer -pbeer -h192.168.1.100 ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.100' (111) beer@beer-laptop# mysql -ubeer -pbeer -hlocalhost Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 160 Server version: 5.1.31-1ubuntu2 (Ubuntu) Type 'help;' or 'h' for help. Type 'c' to clear the buffer. mysql> beer@beer-laptop# mysql -ubeer -pbeer -h127.0.0.1 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 161 Server version: 5.1.31-1ubuntu2 (Ubuntu) Type 'help;' or 'h' for help. Type 'c' to clear the buffer. mysql> </pre> <p>Error 111 also occurs when connecting from another machine. </p> <pre>another@another-laptop# mysql -ubeer -pbeer -h192.168.1.100 ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.100' (111) </pre> <p>In this case, what is the difference between using localhost or 127.0.0.1 versus using 192.168.1.100? I don't know how to connect to this database from another machine. <br /><br />Please help, thank you. </p><p><br /></p>
P粉236743689P粉236743689414 days ago686

reply all(2)I'll reply

  • P粉936509635

    P粉9365096352023-08-03 17:12:25

    111 means connection refused, which means your mysqld is only listening on the localhost interface.

    To make modifications, you can view the bind-address value of the mysqld section in the my.cnf file.

    reply
    0
  • P粉471207302

    P粉4712073022023-08-03 00:26:15

    This probably means that your MySQL server is only listening on the localhost interface.

    If you have a line similar to:


    bind-address = 127.0.0.1

    In your my.cnf configuration file, you should comment them out (add # at the beginning of the line) and then restart MySQL.

    sudo service mysql restart

    Of course, to perform this operation, you must be the administrator of the server.

    reply
    0
  • Cancelreply