[Solved] QT & MySQL - What must be done? [Beginner]



  • Hi folks,

    I want to start accessing a MySQL-DB programatically with Qt.

    The basic question is - what do I have to do?

    Here is my setup:
    qt-opensource-windows-x86-msvc2013_64_opengl-5.3.1
    Windows8.1 64bit
    Visual Studio 2013 Express
    MySQL (I installed nearly everything, connectors, etc, the main version is 5.6 (I think))

    In the Qt-directory plugins/sqldrivers there are already the two files qsqlmysql.dll and qsqlmysqld.dll

    The methodcall QSqlDatabase::isDriverAvailable( "QMYSQL" ) gives me a "true".

    But a call to QSqlDatabase::addDatabase( "QMYSQL" )
    gives the warnings:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    So I think the driver is there but it can't be loaded. What is wrong? Do I have to compile some additional things?

    Many thanks in advance.

    Best regards
    Kai


  • Lifetime Qt Champion

    Hi,

    You need to have the path to the mysql dlls in your PATH environment variable. You can add it in the run part of the Project panel



  • Works - perfect!

    To be a little bit more precise for people who will run into the same problem. On my sytem I had to expand the PATH variable with the following path:
    C:\Program Files\MySQL\MySQL Server 5.6\lib

    Thanks SGaist

    BTW: I did not find this essential hint in the current Qt-docs. Is there a way to add it there?


  • Lifetime Qt Champion

    You have the Troubleshooting section of the "SQL Database Driver" chapter in the documentation but it might use that information.



  • sorry got the same problem but i am not able to fix it...

    got qt 5.3 mingw 32 on 64 bit win 7
    mysql 5.6 dev install

    on linux every thing is fine but Win :(



  • Hi,
    I guess the problem you encounter now is that the libraries of the downloaded MySQL-distribution are for VisualStudio (not MinGW).

    So you must try to fetch the MinGW-libs.

    Regards
    Kai



  • how i change to msvs but still got trouble... can't compline driver ...


  • Lifetime Qt Champion

    It's a bit vague, what errors are you getting ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.