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

QMYSQL Driver not loaded in Ubuntu

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmysqlc++
6 Posts 2 Posters 1.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.
  • D Offline
    D Offline
    Double A
    wrote on last edited by Double A
    #1

    Hi I'm trying to build a program that connect on MySQL, i have this error "QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7"

    But i already "libmysqlclient.so.20" and "libqsqlmysql.so" in my sqldrivers folder. Please do help me, I'm a beginner in QT Programming. Sorry for my grammar.

    I'm using this code

    QSqlDatabase db1 = QSqlDatabase::addDatabase( "QMYSQL" );
    db1.setHostName("127.0.0.1");
    db1.setPort(8080);
    db1.setDatabaseName( "sample" );
    db1.setUserName( "root" );
    db1.setPassword( "" );
    
    if( !db1.open() )
    {
      qDebug() << db1.lastError();
      qFatal( "Failed to connect." );
    }
    qDebug( "Connected!" );
    

    OS : Ubuntu 16.04
    QT Ver : Qt 5.12.0

    jsulmJ 1 Reply Last reply
    0
    • D Double A

      Hi I'm trying to build a program that connect on MySQL, i have this error "QSqlDatabase: QMYSQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7"

      But i already "libmysqlclient.so.20" and "libqsqlmysql.so" in my sqldrivers folder. Please do help me, I'm a beginner in QT Programming. Sorry for my grammar.

      I'm using this code

      QSqlDatabase db1 = QSqlDatabase::addDatabase( "QMYSQL" );
      db1.setHostName("127.0.0.1");
      db1.setPort(8080);
      db1.setDatabaseName( "sample" );
      db1.setUserName( "root" );
      db1.setPassword( "" );
      
      if( !db1.open() )
      {
        qDebug() << db1.lastError();
        qFatal( "Failed to connect." );
      }
      qDebug( "Connected!" );
      

      OS : Ubuntu 16.04
      QT Ver : Qt 5.12.0

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Double-A Set QT_DEBUG_PLUGINS env variable and start your app - you should see why the plug-in was not loaded.
      See "Debugging Plugins" in https://doc.qt.io/qt-5/deployment-plugins.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Double A
        wrote on last edited by
        #3

        @jsulm Can i insert "QT_DEBUG_PLUGINS" in my source code?

        jsulmJ 1 Reply Last reply
        0
        • D Double A

          @jsulm Can i insert "QT_DEBUG_PLUGINS" in my source code?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Double-A You can, but why?
          Go to Run settings of your project in QtCreator and set it there.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Double A
            wrote on last edited by Double A
            #5

            @jsulm i got this error

            QLibraryPrivate::loadPlugin failed on "/home/pc/Qt/5.12.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" : "Cannot load library /home/pc/Qt/5.12.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so: (libmysqlclient.so.18: cannot open shared object file: No such file or directory)"

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

            jsulmJ 1 Reply Last reply
            0
            • D Double A

              @jsulm i got this error

              QLibraryPrivate::loadPlugin failed on "/home/pc/Qt/5.12.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" : "Cannot load library /home/pc/Qt/5.12.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so: (libmysqlclient.so.18: cannot open shared object file: No such file or directory)"

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

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Double-A said in QMYSQL Driver not loaded in Ubuntu:

              libmysqlclient.so.18

              As the error says it can't find libmysqlclient.so.18
              Also don't forget that on UNIX/Linux it is not enough to put the lib in same directory like on Windows.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              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