title: ERROR 2003 (HY000): Can't connect to MySQL server (111)
body: <p>This question is related to the following questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1420839/cant-connect-to-mysql-server-error-111">Can&#39;t connect to MySQL server error 111</a></li>
  <li><a href="https://stackoverflow.com/questions/5713808/trying-to-connect-to-remote-mysql-host-error-2003">Trying to connect to remote MySQL host (error 2003)</a></li>
  </ul>
  
  <p>I am configuring a new MySQL (5.1) server on my local machine. I need to provide remote access to the database. I did the following steps:</p>
  
  <ol>
  <li><p>Comment <code>bind-address</code> in my.cnf: </p>
  
  <pre><code># bind-address      = 192.168.1.3
  </code></pre></li>
  <li><p>Grant privileges:</p>
  
  <pre><code>GRANT ALL PRIVILEGES ON *.* TO 'nickruiz'@'%' IDENTIFIED BY PASSWORD 'xxxx';
  </code></pre></li>
  <li>Set port forwarding on router (TCP and UDP, port 3306, 192.168.1.3)</li>
  <li><p>Configure iptables for firewall</p>
  
  <pre><code>sudo iptables -I INPUT -p udp --dport 3306 -j ACCEPT
  
  sudo iptables -I INPUT -p tcp --dport 3306 --syn -j ACCEPT
  
  sudo iptables-save
  </code></pre></li>
  <li><p>Restart mysql server <code>sudo /etc/init.d/mysql restart</code></p></li>
  </ol>
  
  <p>When testing, I get the following:</p>
  
  <p>LAN:</p>
  
  <pre><code>mysql -h 192.168.1.3 -u nickruiz -p
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 95
  Server version: 5.1.63-0ubuntu0.11.04.1 (Ubuntu)
  </code></pre>
  
  <p>Remote:</p>
  
  <pre><code>mysql -h 1xx.xx.4.136 -u nickruiz -p
  ERROR 2003 (HY000): Can't connect to MySQL server on '1xx.xx.4.136' (111)
  </code></pre>
  
  <p>Clearly there's something wrong that's preventing me from being able to use my global IP address.</p>
  
  <p>Notes: </p>
  
  <ul>
  <li>I've tried testing the remote connection on the same machine and also
  via SSH from a remote machine. </li>
  <li>I'm not sure if my ISP has given me a static IP.</li>
  </ul>
  
  <p>Any ideas?</p>
  
  <p>Update:
  telnet doesn't seem to be working.</p>
  
  <pre><code>telnet 192.168.1.3 3306
  Trying 192.168.1.3...
  Connected to 192.168.1.3.
  Escape character is '^]'.
  E
  5.1.63-0ubuntu0.11.04.1,0g8!:@pX;]DyY0#\)SIConnection closed by foreign host.
  </code></pre>