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. QSqlDatabase: QMYSQL driver not loaded. Why?
Forum Updated to NodeBB v4.3 + New Features

QSqlDatabase: QMYSQL driver not loaded. Why?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 14.3k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    Hi

    I compiled Qt 5.0.2 with MySQL support. Driver plugin is there but program can't load it with a funny message:

    @QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3@

    What am I doing wrong ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Could you post what QSqlDatabase::lastError().text() returns ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        soroush
        wrote on last edited by
        #3

        [quote author="SGaist" date="1364405279"]Hi,

        Could you post what QSqlDatabase::lastError().text() returns ?[/quote]

        It says:
        @
        "Driver not loaded Driver not loaded"
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then, can you post the code where you setup the database connection ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            soroush
            wrote on last edited by
            #5

            [quote author="SGaist" date="1364418685"]Then, can you post the code where you setup the database connection ?[/quote]

            Does it really matter? in first line when I'm trying to create a new database I got this error. I always connect this way, and it always works.

            @
            QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); // This is the line I got error
            db.setHostName("127.0.01");
            db.setDatabaseName("test");
            db.setUserName("root");
            db.setPassword("pass");
            bool ok = db.open();
            @

            Note: I'm using my own build: http://sourceforge.net/p/eboqt/

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Do you have the MySql client dll accessible in your PATH when running your program ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                soroush
                wrote on last edited by
                #7

                [quote author="SGaist" date="1364472156"]Do you have the MySql client dll accessible in your PATH when running your program ?[/quote]

                :| Yes I have it. I found that Qt distros provided by mingwbuilds do the same thing with MySQL on Win 8...

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Sir.Costy
                  wrote on last edited by
                  #8

                  Get the same error with Qt5.3 MINGW install on Windows8

                  @QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLCIPHER QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7@

                  The QSQLCIPHER and QSQLITE drivers are working perfectly...

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Sir.Costy
                    wrote on last edited by
                    #9

                    SOLVED ... have to find and copy the libmysql.dll from the place MYSQL it is installed on the computer to the [QTDIR]/mingw482_32/bin/ folder.
                    Maybe its also working if you add the MYSQL install path to system variables?

                    Just be sure you copy the good dll ...mean that if your Qt installed is 32 bits then will need the 32 bits dll too.
                    My first mistake was to copy the 64 bits dll and was not working

                    Hasan VaezH 1 Reply Last reply
                    1
                    • S Sir.Costy

                      SOLVED ... have to find and copy the libmysql.dll from the place MYSQL it is installed on the computer to the [QTDIR]/mingw482_32/bin/ folder.
                      Maybe its also working if you add the MYSQL install path to system variables?

                      Just be sure you copy the good dll ...mean that if your Qt installed is 32 bits then will need the 32 bits dll too.
                      My first mistake was to copy the 64 bits dll and was not working

                      Hasan VaezH Offline
                      Hasan VaezH Offline
                      Hasan Vaez
                      wrote on last edited by
                      #10

                      @Sir.Costy For me worked by copying libmysql.dll from MYSQL folder to [QTDIR]/mingw482_32/bin/ folder.
                      Thanks male!

                      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