title: QSqlDatabase: QMYSQL driver not loaded on Mac OS
body: <p>I've already solved this problem on Windows and some Linux flavors, now is Mac time. It all starts with the following:</p>
  
  <pre><code>QSqlDatabase: QMYSQL driver not loaded
  QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
  </code></pre>
  
  <p>Then the solution should be more or less what is pointed in the following links i.e.:</p>
  
  <p><a href="https://stackoverflow.com/questions/7579212/mysql-for-qt-on-mac">MySQL for Qt on Mac</a></p>
  
  <p><a href="https://stackoverflow.com/questions/37515236/qsqldatabase-qmysql-driver-not-loaded-on-xubuntu-16-04-64bits">QSqlDatabase: QMYSQL driver not loaded on Xubuntu 16.04 64bits</a></p>
  
  <p><a href="https://stackoverflow.com/questions/37369480/qsqldatabase-qmysql-driver-not-loaded-on-ubuntu-15-04-64bits">QSqlDatabase: QMYSQL driver not loaded on Ubuntu 15.04 64bits</a></p>
  
  <p>In the end a new version of (debug and release) the lib should be produced, then is a matter of replacing the old one by the new one and everything will work from now on.</p>
  
  <p>I just did that and the problem is that the new lib (found in <code>~Qt/5.7/Src/qtbase/plugins/sqldrivers</code>), the one just compiled with</p>
  
  <pre><code>~/Qt/5.7/clang_64/bin/qmake "INCLUDEPATH += /usr/local/mysql-5.6.17-osx10.7-x86_64/include/" "LIBS += -L/usr/local/mysql-5.6.17-osx10.7-x86_64/lib/"
  make
  </code></pre>
  
  <p>have the same size as the older (found in <code>~Qt/5.7/clang_64/plugins/sqldrivers</code>). I mean, the lib just compiled is the same as the one already there. And I still get the <code>QSqlDatabase: QMYSQL driver not loaded</code>.</p>
  
  <p>Can some one please put some light here? What's going on?</p>
  
  <p>After some time I found (<a href="http://www.qtcentre.org/threads/27606-Qt-Mysql-on-Mac-OS-X" rel="nofollow noreferrer">here</a>) that</p>
  
  <pre><code>install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib
  </code></pre>
  
  <p>and </p>
  
  <pre><code>install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
  </code></pre>
  
  <p>helps.</p>
  
  <p>I have some understanding of this but I'll leave it open to someone more knowledgeable in the field to give the details. </p>