title: Bash script fails to connect remote MySQL while it is possible to access it manually
body: <p>I need to write a bash script which would connect to MySQL server on remote host with below command:</p>
  <pre><code>$MYSQL_HOME/bin/mysql --socket=$MYSQL_UNIX_PORT -u$MYSQL_USER -p$MYSQL_PWD --host $x --connect-timeout=5 -e 'show master status'
  </code></pre>
  <p>The script finds 2 database servers (10.5.5.233 and 10.5.5.234) in the config file and it tries to access to each of these hosts. However, the connection fails with &quot;No route to host&quot;:</p>
  <pre><code>ERROR 2003 (HY000): Can't connect to MySQL server on '10.5.5.233' (113 &quot;No route to host&quot;)
  ERROR 2003 (HY000): Can't connect to MySQL server on '10.5.5.234' (113 &quot;No route to host&quot;)
  </code></pre>
  <p>On the other hand, the connection to the master database succeeds when I try to connect it manually:</p>
  <pre><code>$MYSQL_HOME/bin/mysql --socket=$MYSQL_UNIX_PORT -u$MYSQL_USER -p$MYSQL_PWD --host 10.5.5.233 --connect-timeout=5 -e 'show master status'
  +------------------------+----------+-----------------------------------------------+------------------+
  | File                   | Position | Binlog_Do_DB                                  | Binlog_Ignore_DB |
  +------------------------+----------+-----------------------------------------------+------------------+
  | xxx-bin.000006 | 65284117 | xxx,sched,qua,tadb,nodb |                  |
  +------------------------+----------+-----------------------------------------------+------------------+
  </code></pre>
  <p>I could not find any similar post what could cause this behavior.
  Could you please help me understand why bash script fails to connect to MySQL on remote host while the same command succeeds when I run it manually?
  Thanks.</p>