Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [solved] QtSql and XAMPP MySql - "QMYSQLdriver not loaded"
Forum Updated to NodeBB v4.3 + New Features

[solved] QtSql and XAMPP MySql - "QMYSQLdriver not loaded"

Scheduled Pinned Locked Moved Installation and Deployment
12 Posts 3 Posters 7.8k Views 3 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.
  • K Offline
    K Offline
    killerman
    wrote on 14 Apr 2015, 15:12 last edited by killerman
    #1

    Hi, I' ve installed XAMPP and i've created a database but i get error while opening it.

    Here is my programm:

    QCoreApplication a(argc, argv);
    
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("people");
    db.setUserName("root");
    db.setPassword("");
    
    if(db.open())  qDebug() << "Opened";
    else qDebug() << "Not opened";
    
    return a.exec();
    

    i get en error:

    QsqlDatabase: QMYSQL driver not loaded
    QsqlDatabase: available drivers ... QMYSQL...
    

    So, the driver is installed byt it wont work.

    What is wrong ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on 14 Apr 2015, 15:56 last edited by
      #2

      Hi and welcome to devnet,

      I think there are a lot of similar threads in the forum; BTW the first thing to check is if the MySQL client library (not the Qt driver) is available in the PATH.

      QSqlDatabase::drivers() return the list on Qt drivers installed on the machine.
      When you try to use a driver, it needs to load the native DB client library; if the client library cannot be loaded the driver loading fails.

      This is why you can see the driver as available but you're not able to load it.

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      1
      • K Offline
        K Offline
        killerman
        wrote on 14 Apr 2015, 16:56 last edited by
        #3

        "BTW the first thing to check is if the MySQL client library (not the Qt driver) is available in the PATH."

        It is not. This is my PATH.

        PATH=C:\Documents and Settings\All Users\Dane aplikacji\Oracle\Java\javapath;
        D:\aplikacje\Borland\CBUILD~1\Bin ;
        D : \Ap1ikacje\Borland\CBUILD~1\Projects\Bp1;
        C:\WINDOWS\system32;
        C:\WINDOWS ;
        C:\WINDOWS\system32\wbem;
        C:\PROGRAM FILES\QUICKTIME\QTSYSTEM;
        D:\Aplikacje\Internet Explorer;
        C:\Program Files\QuickTime \QTSystem;

        I've tried to use the code below(in cmd) but it still don't work...

         set PATH=C:\xampp\mysql
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on 14 Apr 2015, 16:58 last edited by
          #4

          Hi,

          you need to set it as System environmental variable

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          1
          • K Offline
            K Offline
            killerman
            wrote on 14 Apr 2015, 17:14 last edited by
            #5

            Ok. I did it using this tutorial:
            http://www.computerhope.com/issues/ch000549.htm#windowsxp

            but QT still gives the same error...

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 14 Apr 2015, 23:27 last edited by
              #6

              Hi and welcome to devnet,

              What does QSqlDatabase::lastError() return ?

              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
              1
              • K Offline
                K Offline
                killerman
                wrote on 15 Apr 2015, 04:54 last edited by
                #7

                it returns:

                "QSqlError<"", "Driver not loaded", "Driver not loaded">"

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mcosta
                  wrote on 15 Apr 2015, 05:40 last edited by
                  #8

                  HI,

                  can you show again your PATH? Is the mysqlclient.dll in the PATH?

                  Once your problem is solved don't forget to:

                  • Mark the thread as SOLVED using the Topic Tool menu
                  • Vote up the answer(s) that helped you to solve the issue

                  You can embed images using (http://imgur.com/) or (http://postimage.org/)

                  1 Reply Last reply
                  1
                  • K Offline
                    K Offline
                    killerman
                    wrote on 15 Apr 2015, 15:06 last edited by
                    #9

                    PATH=C:\Documents and Settings\All Users\Dane aplikacji\Oracle\Java\javapath;
                    D:\aplikacje\Borland\CBUILD~1\Bin ;
                    D : \Ap1ikacje\Borland\CBUILD~1\Projects\Bp1;
                    C:\WINDOWS\system32;
                    C:\WINDOWS ;
                    C:\WINDOWS\system32\wbem;
                    C:\PROGRAM FILES\QUICKTIME\QTSYSTEM;
                    D:\Aplikacje\Internet Explorer;
                    C:\Program Files\QuickTime \QTSystem;
                    C:\xampp\mysql;

                    I've added the folder with mysql in xampp. Is it wrong?

                    i've searched for mysqlclient.dll in xampp file but it is not there.

                    There are only mysqlclient.lib files in .../xampp/lib and .../xampp/lib/debug

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mcosta
                      wrote on 15 Apr 2015, 15:10 last edited by
                      #10

                      you need to add C:\xampp\lib in the PATH

                      Once your problem is solved don't forget to:

                      • Mark the thread as SOLVED using the Topic Tool menu
                      • Vote up the answer(s) that helped you to solve the issue

                      You can embed images using (http://imgur.com/) or (http://postimage.org/)

                      1 Reply Last reply
                      1
                      • K Offline
                        K Offline
                        killerman
                        wrote on 15 Apr 2015, 15:53 last edited by
                        #11

                        Ok. It works fine now.

                        Thank You :)

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mcosta
                          wrote on 15 Apr 2015, 15:56 last edited by
                          #12

                          You're welcome.
                          Don't forget to mark the thread as SOLVED

                          Once your problem is solved don't forget to:

                          • Mark the thread as SOLVED using the Topic Tool menu
                          • Vote up the answer(s) that helped you to solve the issue

                          You can embed images using (http://imgur.com/) or (http://postimage.org/)

                          1 Reply Last reply
                          0

                          1/12

                          14 Apr 2015, 15:12

                          • Login

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