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 - again?...
Forum Updated to NodeBB v4.3 + New Features

QMYSQL driver not loaded - again?...

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 2 Posters 4.3k Views 2 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.
  • M Offline
    M Offline
    mr__710
    wrote on last edited by
    #1

    Hello,
    as i am quite new to this topic, i read many other posts to the mysql errors but still got problems to understand.

    My program already works with a database on my computer made by sqlite. Now i want to change it, so that i can read from a database on a webserver. I installed xampp and created a database. The changes in my code are the following:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("tempdata");
    db.setPort(3306);
    db.open();
    

    I included <QSql> in the header and QTPLUGIN += qsqlmysql in .pro-File.
    When i run the programm it gets me the error:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    "Driver not loaded Driver not loaded"
    QSqlQuery::exec: database not open
    "Driver not loaded Driver not loaded"
    QSqlQuery::value: not positioned on a valid record

    My system is Windows 10. Please help me or link a related post, so that i can understand :)

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

      Hi
      If the database server is on other computer then
      db.setHostName("localhost");
      should be ip or name of that server as far as I know.
      localhost cannot be "other" pc.
      Also note the port 3306.
      Might be blocked by windows firewall.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mr__710
        wrote on last edited by
        #3

        okay, but this is not the problem, i think.

        I read of copying files like libmysql.dll and so on,
        but i do not understand what i exactly have to do :/

        mrjjM 1 Reply Last reply
        0
        • M mr__710

          okay, but this is not the problem, i think.

          I read of copying files like libmysql.dll and so on,
          but i do not understand what i exactly have to do :/

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @mr__710
          well does it still work to load database from own pc?

          did u read this ?
          https://forum.qt.io/topic/25638/qsqldatabase-qmysql-driver-not-loaded-why

          1 Reply Last reply
          1
          • M Offline
            M Offline
            mr__710
            wrote on last edited by
            #5

            with data.db on my pc it worked.

            db = QSqlDatabase::addDatabase("QSQLITE");
            db.setDatabaseName("C:/sqlite/data.db");
            

            this was no problem.

            mrjjM 1 Reply Last reply
            0
            • M mr__710

              with data.db on my pc it worked.

              db = QSqlDatabase::addDatabase("QSQLITE");
              db.setDatabaseName("C:/sqlite/data.db");
              

              this was no problem.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mr__710 said

              ok, so now you will use
              QMYSQL
              and you did install MYSQL on your pc and copied the DLL so qt can use it ?
              and you must also use
              IP in db.setHostName
              if the database is on other pc.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mr__710
                wrote on last edited by
                #7

                I installed MYSQL to c://MySql.
                What files do i have to copy and in which folder of QTdir?

                mrjjM 1 Reply Last reply
                0
                • M mr__710

                  I installed MYSQL to c://MySql.
                  What files do i have to copy and in which folder of QTdir?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  it depends on your qt version but this for 5
                  http://seppemagiels.com/blog/create-mysql-driver-qt5-windows
                  Step 5

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mr__710
                    wrote on last edited by
                    #9

                    Perfect, with mingw it works now.
                    Unfortunately i have to compile it on android with armeabi-v7.

                    There i get errors again, what do i have to change?

                    mrjjM 1 Reply Last reply
                    0
                    • M mr__710

                      Perfect, with mingw it works now.
                      Unfortunately i have to compile it on android with armeabi-v7.

                      There i get errors again, what do i have to change?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @mr__710 ¨
                      uhh, sorry. I have no idea about android.
                      Maybe open new topic with errors from android building?

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mr__710
                        wrote on last edited by mr__710
                        #11

                        ok, thank you so far.

                        If someone wants to help: http://forum.qt.io/topic/61141/mysql-database-connection-mingw-yes-android-no

                        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