Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMYSQL driver not loaded Error

QMYSQL driver not loaded Error

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rezaMSLM
    wrote on last edited by
    #1

    Re: QSqlDatabase: QMYSQL driver not loaded available drivers: QMYSQL

    I have the same problem.
    I read the question and answers in many topics that had my problem but couldn't solve my problem.
    I use Qt 5.9.6 mingw32 and 64 bit windows,i have MySql 5.7 installed.
    I don't know how to build the drivers myself(if it is necessary).
    here is my system path:

    C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
    %SystemRoot%\system32;
    %SystemRoot%;%SystemRoot%\System32\Wbem;
    %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
    C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;
    C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;
    C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;
    C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;
    C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;
    C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;
    C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;
    C:\Strawberry\perl\bin;
    C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;
    C:\Program Files\IVI Foundation\VISA\Win64\Bin\;
    C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;
    C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;
    C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\
    

    my code has only one line:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    

    and I have added qt += sql in my .pro file

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Do you have mysql plugin under plugins/sqldriver directory ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      R 1 Reply Last reply
      0
      • dheerendraD dheerendra

        Do you have mysql plugin under plugins/sqldriver directory ?

        R Offline
        R Offline
        rezaMSLM
        wrote on last edited by
        #3

        @dheerendra said in QMYSQL driver not loaded Error:

        Do you have mysql plugin under plugins/sqldriver directory ?

        is it a *.dll file?if yes , No thereis not any *.dll file in that directory

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rezaMSLM
          wrote on last edited by
          #4

          I Found this answer on web:

          When you download Qt you have also the source that are provided with it.
          
          In my case, it is in : C:\Qt\5.9\Src\qtbase\src\plugins\sqldrivers\mysql Here you have a *.pro (that is a kind of makefile generator). You just have to open it with QtCreator, Compile it and you will get a dll. This dll is the MySQL driver and must be in the same dirent of your application.
          

          but when i want to compile the file I receive this error:

           Library 'mysql' is not defined.
          
          1 Reply Last reply
          0
          • R Offline
            R Offline
            rezaMSLM
            wrote on last edited by rezaMSLM
            #5

            i want to build the driver myself using this command:

            cd %QTDIR%\qtbase\src\plugins\sqldrivers
            qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt"
            nmake sub-mysql
            

            my MySQL folder location is : C:\Program Files\MySQL
            so i use this code:
            qmake -- MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
            but I Receive this error:

            library mysql not defined
            
            JonBJ 1 Reply Last reply
            0
            • R rezaMSLM

              i want to build the driver myself using this command:

              cd %QTDIR%\qtbase\src\plugins\sqldrivers
              qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt"
              nmake sub-mysql
              

              my MySQL folder location is : C:\Program Files\MySQL
              so i use this code:
              qmake -- MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
              but I Receive this error:

              library mysql not defined
              
              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @rezaMSLM
              Because your folder name has spaces in it, when you changed the command line you don't seem to have done the necessary quoting? Does the following work better:

              qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
              

              Otherwise, although it may be OK, you are mixing \s and /s in your version, is that an issue?

              R 1 Reply Last reply
              2
              • JonBJ JonB

                @rezaMSLM
                Because your folder name has spaces in it, when you changed the command line you don't seem to have done the necessary quoting? Does the following work better:

                qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
                

                Otherwise, although it may be OK, you are mixing \s and /s in your version, is that an issue?

                R Offline
                R Offline
                rezaMSLM
                wrote on last edited by rezaMSLM
                #7

                @JonB said in QMYSQL driver not loaded Error:

                @rezaMSLM
                Because your folder name has spaces in it, when you changed the command line you don't seem to have done the necessary quoting? Does the following work better:

                qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
                

                Otherwise, although it may be OK, you are mixing \s and /s in your version, is that an issue?

                I Tried both

                qmake -- MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 5.7/include "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 5.7/lib/opt"
                

                and

                qmake -- "MYSQL_INCDIR=C:/Program Files/MySQL/MySQL Server 5.7/include" "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Server 5.7/lib/opt"
                

                but receive the same error:

                D:\Qt\Qt5.9.6\5.9.6\Src\qtbase\src\plugins\sqldrivers\qtsqldrivers-config.pri: the system cannot find the file specified.
                project ERROR: Library 'mysql' is not defined.
                

                EDIT:

                I have no folder named "opt" in "C:/Program Files/MySQL/MySQL Server 5.7/lib"
                my mysql.h file is in

                C:\Program Files\MySQL\MySQL Server 5.7\include
                

                and libmysql.lib is in

                C:\Program Files\MySQL\MySQL Server 5.7\lib
                

                so I used this code:

                qmake -- "MYSQL_INCDIR=C:/Program Files/MySQL/MySQL Server 5.7/include" "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Server 5.7/lib"
                

                but have the same error

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rezaMSLM
                  wrote on last edited by
                  #8

                  For people that have this Problem:
                  this solved my problem

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved