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. [Solved]Qt5.2 can find the mysql driver but can not load it
Forum Updated to NodeBB v4.3 + New Features

[Solved]Qt5.2 can find the mysql driver but can not load it

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 13.0k 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
    stereomatching
    wrote on last edited by
    #1

    os : win7
    compiler : mingw4.8(come with Qt5.2)

    @db = new QSqlDatabase();
    db->addDatabase("QMYSQL");
    db->setHostName("localhost");
    db->setDatabaseName("myclinic");
    db->setUserName("root");
    db->setPassword(",trth12");

    qDebug() << loader.errorString();
    qDebug() << "drivers: "<< QSqlDatabase::drivers();
    
    if (db->open())
        qDebug() << "Success!";
    else
        qDebug() << db->lastError().text();@
    

    messages
    *QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL
    7
    "The shared library was not found."
    drivers: ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")

    "Driver not loaded Driver not loaded"*

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      SQL works in plugin concept. Looks like plugin for mysql is missing in your installation. Look at ../plugins/sqldrivers directory and check whether appropriate shared library exist.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

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

        [quote author="Dheerendra" date="1389242730"]SQL works in plugin concept. Looks like plugin for mysql is missing in your installation. Look at ../plugins/sqldrivers directory and check whether appropriate shared library exist.[/quote]

        but the available printed by "errorString" show that QMYSQL is supported

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bkerdev
          wrote on last edited by
          #4

          It is yourself who have build the MySQL dll?

          Boris Bker

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

            Hi,

            You can have the plugin built and it will show up in the list of available Sql plugins. However you still need to have the MySQL dlls available on your system (e.g. have the folder where the MySql dlls are installed in your PATH environment variable)

            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
            • B Offline
              B Offline
              Beowolve
              wrote on last edited by
              #6

              It is possible that this is a debug/release problem.

              Make sure you have both:
              qsqlmysql.dll
              qsqlmysqld.dll (this is needed for debug)

              The DLLs need to be in your QT plugins/sqldrivers path, or if you plan to release you application make sure you have a sqldrivers path relative to your executable (allways works for me).

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

                Thanks, I solved the problem.looks like win7 do not come with the dll
                A video show you how to install mysql on windows
                "video":http://www.youtube.com/watch?v=AqQc3YqfelE''

                After install, if you still can't load the driver, go to the lib folder of mysql, copy the libmysql.dll and drop it into the same folder of your exe.

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

                  AFAIK, no version of Windows comes with MySQL pre-installed (the same for OS X and Linux)

                  Linux might be an exception since depending on what package you want to install it may come as a dependency

                  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

                  • Login

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