<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="debugging-client">
      </a>
      7.9.2 Debugging a MySQL Client
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045253581440">
  </a>
  <a class="indexterm" name="idm46045253579984">
  </a>
  <p>
   To be able to debug a MySQL client with the integrated debug
      package, you should configure MySQL with
   <a class="link" href="source-configuration-options.html#option_cmake_with_debug">
    <code class="option">
     -DWITH_DEBUG=1
    </code>
   </a>
   . See
   <a class="xref" href="source-configuration-options.html" title="2.8.7 MySQL Source-Configuration Options">
    Section 2.8.7, “MySQL Source-Configuration Options”
   </a>
   .
  </p>
  <a class="indexterm" name="idm46045253576256">
  </a>
  <a class="indexterm" name="idm46045253575216">
  </a>
  <p>
   Before running a client, you should set the
   <code class="literal">
    MYSQL_DEBUG
   </code>
   environment variable:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa89696192"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">MYSQL_DEBUG</span><span class="token attr-value"><span class="token punctuation">=</span>d:t:O,/tmp/client.trace</span>
<span class="token prompt">$&gt; </span><span class="token command">export</span> MYSQL_DEBUG</code></pre>
  </div>
  <p>
   This causes clients to generate a trace file in
   <code class="filename">
    /tmp/client.trace
   </code>
   .
  </p>
  <p>
   If you have problems with your own client code, you should attempt
      to connect to the server and run your query using a client that is
      known to work. Do this by running
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   in
      debugging mode (assuming that you have compiled MySQL with
      debugging on):
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa71140295"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysql</span> <span class="token constant">--debug</span><span class="token attr-value"><span class="token punctuation">=</span>d:t:O,/tmp/client.trace</span></code></pre>
  </div>
  <p>
   This provides useful information in case you mail a bug report.
      See
   <a class="xref" href="bug-reports.html" title="1.6 How to Report Bugs or Problems">
    Section 1.6, “How to Report Bugs or Problems”
   </a>
   .
  </p>
  <p>
   If your client crashes at some 'legal' looking code, you should
      check that your
   <code class="filename">
    mysql.h
   </code>
   include file matches
      your MySQL library file. A very common mistake is to use an old
   <code class="filename">
    mysql.h
   </code>
   file from an old MySQL installation
      with new MySQL library.
  </p>
 </div>
 <br/>
</div>
