Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql remote connection - mysql CL client works, C++ app doesn't
    primarykey
    data
    text
    <p>Strange problem here. I have a C++ application that I've written using the MySQL C library. It does the following:</p> <ul> <li>connects to a remote MySQL server</li> <li>retrieve some data</li> <li>analyze data</li> <li>push the results back to DB server</li> <li>close db</li> </ul> <p>The MySQL server is v5.1.61 on CentOS 6 The client runs fine from the command line on various linux distros - CentOS 6, Ubuntu, Scientific Linux 6.4</p> <p>It works fine on all of these machines, except one specific Scientific Linux 6.3 box. Which happens to be the cluster head node - ie. where I need to go to get to the real horsepower!</p> <p>When I try to run it here I get the following:</p> <pre><code>2003 : Can't connect to MySQL server on 'hostname' (111) </code></pre> <p>AFAIK, this typically indicates a permission or networking issue.</p> <p>However, I can connect to the server via the mysql command line client with the identical credentials.</p> <p>What I've tried:</p> <ul> <li>Connected to server from the problem machine with command line mysql client. Rules out permission issues or bad credentials.</li> <li>recompiled the the C++ exe (g++ 4.4.7) on this box to make sure it isn't some sort of library incompatibility. No change.</li> <li>I've tried this with both the server host name and IP address with the same behavior. Rules out name resolution problem.</li> <li>Tried connecting to a different MySQL server with both my exe and the CL client - same behavior. Indicates a client issue not the specific mysql server</li> </ul> <p>The C++ code uses mysql_real_connect() from the mysql C library. I've used this same connection code for years in many different programs and many different databases - it works. Until now.</p> <pre><code>int MakeDbConnect(MYSQL **db, const string &amp;dbserver, const string &amp;dbname, const string &amp;dbuser, const string &amp;dbpasswd) { *db = mysql_init(NULL); if (mysql_real_connect(*db, dbserver.c_str(), dbuser.c_str(), dbpasswd.c_str(), dbname.c_str(), 0, NULL, 0) == NULL) { cout &lt;&lt; "ERROR: Call to mysql_real_connect() failed:\t" &lt;&lt; mysql_errno(*db) &lt;&lt; "\t:\t" &lt;&lt; mysql_error(*db) &lt;&lt; endl; cout &lt;&lt; "\tServer: \t" &lt;&lt; dbserver &lt;&lt; endl; cout &lt;&lt; "\tDatabase:\t" &lt;&lt; dbname &lt;&lt; endl; cout &lt;&lt; "\tUser: \t" &lt;&lt; dbuser &lt;&lt; endl; return -1; } return 0; } </code></pre> <p>So again,</p> <ul> <li>this executable works fine from several other linux boxes.</li> <li>It doesn't connect from one particular box</li> <li>The linux command line mysql client can connect from this same box using identical credentials</li> </ul> <p>All of these systems are inside our corporate firewall and run by the same group. So they should all have a very similar configuration.</p> <p>Any ideas? Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload