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

QMYSQL Driver not loaded

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

    I've installed Qt5.6.0 just now and I'm getting the error when trying to connect to the database. my code is very simple just trying to test to see if I can connect to the database I've set up. It's a MariaDB database. How can I fix this?

    This is What I get:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    "Driver not loaded Driver not loaded"
    

    my code is:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("192.168.43.252");
        db.setDatabaseName("readers");
        db.setUserName("moki");
        db.setPassword("mapra");
        if(!db.open())
            qDebug() << db.lastError().text();
    
    1 Reply Last reply
    1
    • H Offline
      H Offline
      hrompato
      wrote on last edited by hrompato
      #2

      You have already compiled the driver?
      Download from here: https://dev.mysql.com/downloads/connector/cpp/ and follow the instruccions:
      http://doc.qt.io/qt-4.8/sql-driver.html

      You need a sqldriver folder with the plugin under your run directory

      M 1 Reply Last reply
      1
      • H hrompato

        You have already compiled the driver?
        Download from here: https://dev.mysql.com/downloads/connector/cpp/ and follow the instruccions:
        http://doc.qt.io/qt-4.8/sql-driver.html

        You need a sqldriver folder with the plugin under your run directory

        M Offline
        M Offline
        morkia
        wrote on last edited by
        #3

        @hrompato I've installed it using the installer. Do I have to compile it by myself?

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hrompato
          wrote on last edited by
          #4

          Yes, see my comments over

          M 2 Replies Last reply
          0
          • H hrompato

            Yes, see my comments over

            M Offline
            M Offline
            morkia
            wrote on last edited by
            #5

            @hrompato will it work if I install libmysqlcppconn-dev using my package manager?

            H 1 Reply Last reply
            0
            • H hrompato

              Yes, see my comments over

              M Offline
              M Offline
              morkia
              wrote on last edited by morkia
              #6

              @hrompato I'm sorry but I can't figure out how to do the things you just mentioned could you explain how to do them in more details? There's no directory name src/plugins/sqldrivers/mysql anywhere within my Qt installation path.

              1 Reply Last reply
              0
              • M morkia

                @hrompato will it work if I install libmysqlcppconn-dev using my package manager?

                H Offline
                H Offline
                hrompato
                wrote on last edited by
                #7

                @morkia in Linux, if you install libmysqlcppconn, doesn't need compile the plugin.
                Try it

                M 2 Replies Last reply
                0
                • H hrompato

                  @morkia in Linux, if you install libmysqlcppconn, doesn't need compile the plugin.
                  Try it

                  M Offline
                  M Offline
                  morkia
                  wrote on last edited by
                  #8

                  @hrompato I did but the problem is still there.

                  1 Reply Last reply
                  0
                  • H hrompato

                    @morkia in Linux, if you install libmysqlcppconn, doesn't need compile the plugin.
                    Try it

                    M Offline
                    M Offline
                    morkia
                    wrote on last edited by morkia
                    #9
                    This post is deleted!
                    H 1 Reply Last reply
                    0
                    • M morkia

                      This post is deleted!

                      H Offline
                      H Offline
                      hrompato
                      wrote on last edited by
                      #10

                      @morkia It works for me
                      I'm using /usr/lib/libmysqlcppconn.so.7 and Qt5.5.1 in Debian.

                      What is the distribution that you use?
                      You have declared Qt + = sql in the pro file?

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

                        Here's what I did. I just compiled the plugin in Src/qtbase/src/plugins/sqldrivers/mysql using qmake mysql.pro and then make and make install and that did the trick. I also Installed libmysqlcppconn7 and libmysqlcppconn-dev by apt-get.

                        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