Results 1 to 12 of 12

Thread: Qt 5.2 with MySQL- driver not loaded

  1. #1
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Qt 5.2 with MySQL- driver not loaded

    Hello there,
    I’ve downloaded and installed Qt 5.2 32 bit for android, my machine is windows 8 64bit, I also have visual studio 2012 installed, MySQL 5.6.16 32bit is installed.

    I’m trying to connect to a MySQL database, but I always get this error

    QSqlDatabse: QMYSQL driver not loaded
    QSqlDatabse: available drivers: QSQLIT QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7


    Here is my code
    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QtSql>
    3. #include <QtDebug>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QCoreApplication a(argc, argv);
    8. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    I’ve known that in Qt 5.2 there is no need to build the driver, anyway I’v tried and built it but with no difference, I don’t know if the built process went well or no.
    Any suggestions please because I spent the last two days searching the net for a solution.
    Thanks

  2. #2
    Join Date
    Jul 2011
    Location
    Italy
    Posts
    24
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt 5.2 with MySQL- driver not loaded

    I had a similar problem with the PostgreSQL driver on Windows (which, as the mysql driver, is present in the plugins directory and there's no need to build it).
    The problem was not the driver but a PostgreSQL dll. Probably it's the same problem with MySQL.
    Try to use depends to check what dlls the plugin needs (qsqlmysql.dll) and copy them to your build directory (or add in your PATH the directory containing them).

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt 5.2 with MySQL- driver not loaded

    The Qt plugins for MySQL/PostgreSQL/ODBC are shipped in the binary download (because too many people were unable to grasp building them) but the Mysql/PostgreSQL/ODBC client libraries/drivers are not bundled.

    You need to install at least the MySql Connector: http://dev.mysql.com/downloads/connector/c/

  4. #4
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Qt 5.2 with MySQL- driver not loaded

    @sakya I don't know which file to check with dependency walker.

    I found the file qsqlmysql.dll in these directories
    C:\Qt\Qt5.2.0\Tools\QtCreator\bin\plugins\sqldrive rs
    C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins\sqldrivers
    C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins\sqldrivers
    and I added them to the environment PATH, I still have the same error

    @ChrisW67 I downloaded and installed the connector, but with no hope

  5. #5
    Join Date
    Jul 2011
    Location
    Italy
    Posts
    24
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt 5.2 with MySQL- driver not loaded

    Quote Originally Posted by Baso View Post
    @sakya I don't know which file to check with dependency walker.
    The mysql plugin dll is qsqlmysql.dll

    The only mysql dependency should be LIBMYSQL.DLL

  6. #6
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Qt 5.2 with MySQL- driver not loaded

    I found the file qsqlmysql.dll in this path C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins\sqldrivers and I run dependacy walker on it and here is a photo of what I got
    Capture1.jpg

    any tips?

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt 5.2 with MySQL- driver not loaded

    Put the Mysql runtime library (libmysql.dll) on the runtime PATH for the process or system PATH... Just like any other DLL the program has to be able to find it to use it.
    http://msdn.microsoft.com/en-us/library/7d83bc18.aspx

  8. #8
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Qt 5.2 with MySQL- driver not loaded

    Well the path C:\Program Files\MySQL\MySQL Server 5.6\lib which include the libmysql.dll is already in the system PATH !

  9. #9
    Join Date
    Jan 2014
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5.2 with MySQL- driver not loaded

    You have to install the 32-bit MySQL-ODBC-Driver

  10. #10
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Qt 5.2 with MySQL- driver not loaded

    @Willi already installed

  11. #11
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Qt 5.2 with MySQL- driver not loaded

    <SOLVED> the problem was that I downloaded the offline MySQL installer for windows(x86-32bit) the installer is 32bit, but the server combined with it was (5.6 64bit) looks like there is no 5.6 server 32bit so I installed the 5.5 32bit server instead and it worked.

    Thank you all for your help.

  12. #12
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Lightbulb Re: Qt 5.2 with MySQL- driver not loaded

    Since this is the first thread that comes up in google when you search for "MySQL- driver not loaded" error

    update on this when it comes to mysql 5.7.10
    the mysql 32 bit installation will install and leave you a x64 dll. this will not work with qt 32 bit qtmysql plugin

    you do not need to build Qt mysql plugin since its already there when you install (tested with qt 5.5 : Qt\Qt5.5.0\5.5\[compiler]\plugins\sqldrivers)

    what you need to do is install the mysql C connector ( not the C++ one) .
    This will give you a libmysql.dll inside you connector lib path (C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib)

    use this dll with qsqlmysqld.dll that you already have inside the Qt folder.

Similar Threads

  1. MySQL driver , I have, it still not loaded
    By bigkoma in forum Qt Programming
    Replies: 14
    Last Post: 30th January 2011, 11:38
  2. MySQL Driver not loaded on PC without Qt
    By KTvsPeacock in forum Installation and Deployment
    Replies: 39
    Last Post: 20th September 2010, 22:37
  3. Sql Driver: MYSQL not loaded
    By stilgar in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2010, 11:35
  4. MySQL driver not loaded
    By hami in forum Installation and Deployment
    Replies: 1
    Last Post: 12th May 2009, 20:54
  5. MySql Driver not loaded
    By eekhoorn12 in forum Installation and Deployment
    Replies: 13
    Last Post: 18th June 2007, 14:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.