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. [Windows] mysql compiled, available but not loaded
Qt 6.11 is out! See what's new in the release blog

[Windows] mysql compiled, available but not loaded

Scheduled Pinned Locked Moved General and Desktop
15 Posts 8 Posters 19.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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #2

    Ok, I moved libmysql.dll in my application directory and now I get: @Debug: qApp->libraryPaths() = C:/Qt/4.7-x86/plugins - E:/Dev/SQLMsvc/release
    Debug: QSqlDatabase::drivers() = QSQLITE - QMYSQL3 - QMYSQL
    Driver not loaded@ So, now the plugin is correcly found, but as soon as I create a new QSqlDatabase("QMYSQL") I get this Driver not loaded error.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #3

      I have the same probelm, can somebody help?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #4

        Can you try setting your PATH environment variable to contain the path to libmysql.dll? It will not help to put libmysql.dll in your application directory or in the plugins directory. In case you don't want to change your environment variable, then you can instead try putting libmysql.dll in yourQtDirectory/bin together with the Qt dlls.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JulienMaille
          wrote on last edited by
          #5

          Where should I put libmysql.dll when redistributing my app?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #6

            best would be to the directory of your binary (exe) file, as that is the first dir that windows scans for dlls.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Thoron
              wrote on last edited by
              #7

              Got the same problem, but nothing helps. I had QMYSQL driver listed as available, also I copied libmysql.dll to QtDir/bin and placed all mysql dlls in my library paths, but still receive:

              QSqlError(-1, "Driver not loaded", "Driver not loaded")

              Any other ideas? Now I'm considering use QODBC.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JulienMaille
                wrote on last edited by
                #8

                Did you tried copying libmysql.dll next to your program exe?

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Thoron
                  wrote on last edited by
                  #9

                  Yep, still nothing. BTW, it's one of my library paths. I tried even with different versions of MySQL Server (the same problems with 5.5 and 5.6).

                  1 Reply Last reply
                  0
                  • TheBadgerT Offline
                    TheBadgerT Offline
                    TheBadger
                    wrote on last edited by
                    #10

                    I do not have experience with MySQL but with PostgreSQL. From what I have found there is sometimes more than just the lib*sql.dll that the app needs to load before the plugin works. Get something like dependency walker and check what is needed by libmysql.dll and add all of those to the app dir, or just copy everything in the bin folder of MySQL into the app dir and check if that does not work.


                    Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      Thoron
                      wrote on last edited by
                      #11

                      Dependency walker has shown nothing additional stuff, so it's not it, but thank you for your hint. Well, I recompiled drivers once again and tried from scratch with most trivial database opening. The code is below.

                      @
                      QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL");
                      db.setHostName("mysql.agh.edu.pl");
                      db.setUserName("thoron");
                      db.setPassword("mypassword");
                      db.setPort(3306);
                      db.setDatabaseName("thoron");

                      if(db.open())
                      {
                          qDebug()<<"Database is open.";
                      }
                      else
                      {
                          qDebug()<<db.lastError();
                      }@
                      

                      What is interesting, that SQL drivers are loaded properly, but I receive error like this:

                      QSqlError(2003, "QMYSQL: Unable to connect", "Can't connect to MySQL server on 'mysql.agh.edu.pl' (10060)")

                      It seems to be sort of an error on the database site. However, I'm still getting it despite firewall being remotely closed. Database is on some mySQL server, not on my machine and I can access it by, for example php script. Do you have any hints on that?

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        JulienMaille
                        wrote on last edited by
                        #12

                        Are you sure this sql server allows connection from outside? I know it's not allowed on my webhost.
                        Try locally first to debug your code.

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          Thoron
                          wrote on last edited by
                          #13

                          It may be sort of this problem. I created mySQL database on my localhost and it can be reached from Qt without any issues. The previous database was off of my student account on my university, so maybe it's not allowed to reach from my machine. Anywa thank you guys for all guidance. I'm getting mad. :)

                          1 Reply Last reply
                          0
                          • francescmmF Offline
                            francescmmF Offline
                            francescmm
                            wrote on last edited by
                            #14

                            For me the solution was to put libmysql.dll into C:\Windows or in the $PATH variable. In addition I have also put qsqlmysql4.dll into a folder named "sqldrivers".

                            That folder is placed in the same place that the executable.

                            1 Reply Last reply
                            1
                            • D Offline
                              D Offline
                              dragonprince77
                              wrote on last edited by
                              #15

                              I tried putting libmysql.dll into C:\Windows (I am using Windows 7). I did not want to deal with the $PATH variable because that's solely in the command line and most of my directories are long filenames.

                              I put qsqlmysql.dll and qsqlmysqld.dll into a folder called sqldrivers in the %ProjectFolder%/Win32/Debug folder along w/ my executable so it's basically:

                              %ProjectFolder%
                              -Win32
                              --Debug
                              ---sqldrivers
                              ----qsqlmysql.dll
                              ----qsqlmysqld.dll

                              I have tried rebuilding the plugin, no use. Someone suggested it as a problem with the database but I had downloaded yesterday MySQL workbench from MYSQL and used that to create the first table of the application. I also (when I read that), went to eclipse and wrote a small application in Java to do the query I was trying to do to start with (basically the 'get all' atomic read function).

                              I'm so close to scrapping QT for SQL and just writing my own wrapper using MySQL itself but like the look of the API if it would JUST work!

                              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