Results 1 to 20 of 20

Thread: QSqlDatabase: QMYSQL driver not loaded but available

  1. #1
    Join Date
    Jul 2013
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QSqlDatabase: QMYSQL driver not loaded but available

    Yeah hello there, I'm really new here.
    So here's the problem.
    Qt Code:
    1. QSqlDatabase: QMYSQL driver not loaded
    2. QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    To copy to clipboard, switch view to plain text mode 
    I've checked many forums already and have done things so far:
    1) This is my .pro file
    Qt Code:
    1. QT += core
    2. QT += sql
    3. QT -= gui
    4.  
    5. TARGET = DB
    6. CONFIG += console
    7. CONFIG -= app_bundle
    8.  
    9. QTPLUGIN += QSQLMYSQL
    10. TEMPLATE = app
    11.  
    12.  
    13. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    2) This is my sqldrivers folder:
    Qt Code:
    1. alex@alex-Laptop:~/Programming/Qt/5.1.0/gcc_64/plugins/sqldrivers$ ls
    2. libqsqlite.so libqsqlmysql.so libqsqlpsql.so
    To copy to clipboard, switch view to plain text mode 

    3) Have also copied sqldrivers folder to project folder.

    Non of these helped an error still exists.
    I have read almost everything about my problem but nothing helped.
    Please help newbie with the fix.

    Thanks in advance

  2. #2
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    post the part of the code where you open the database connection

  3. #3
    Join Date
    Jul 2013
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Qt Code:
    1. db = QSqlDatabase::addDatabase("QMYSQL");
    2.  
    3. db.setHostName("teachinglessons.abcz8.com");
    4. db.setPort(3306);
    5. db.setDatabaseName("teachi4_test");
    6. db.setUserName("alex");
    7. db.setPassword("123");
    8. qDebug()<<db.open();
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Try giving the database a name:
    Qt Code:
    1. db = QSqlDatabase::addDatabase("QMYSQL", "my_sql_db");
    To copy to clipboard, switch view to plain text mode 

    Plus, have you built the plugins?

    http://harmattan-dev.nokia.com/docs/...x-and-mac-os-x

  5. #5
    Join Date
    Jul 2013
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Nothing change unfortunately

  6. #6
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Read my editing, i think you are missing the step of building the plugins

  7. #7
    Join Date
    Jul 2013
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Quote Originally Posted by KillGabio View Post
    Read my editing, i think you are missing the step of building the plugins
    There's no /src/plugins/sqldrivers/mysql in my qt folder should i create it?

    Sorry for stupid question

  8. #8
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    I have this path for example:
    C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\my sqls
    containing main.cpp, mysql.pro and readme.

    Im running on windows, but you should have the same path i assume. Somewhere you need to have the files to generate and build your drivers.

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    You have the Qt plugin for MySQL and it is recognised far enough to tell your program it exists. Are the MySQL run-time libraries (on which an actual database connection would depend) available on your machine?

  10. #10
    Join Date
    Jul 2013
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    KillGabio
    There's nothing like that found in my Qt


    ChrisW67
    Yes but same problem

  11. #11
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    On Windows when I had the same problem i had to include the .dll of the database in this path:
    C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\sqldrivers
    So that the compiler knows the libraries. For example there I have: qsqlite4.dll, qsqlocid4.dll, etc. I think you are missing the same files but for Unix (.so shared objects)

  12. #12
    Join Date
    Jul 2013
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    alex@alex-Laptop:~/Programming/Qt/5.1.0/gcc_64/plugins/sqldrivers$ ls
    libqsqlite.so libqsqlmysql.so libqsqlpsql.so
    I have the libraries there

  13. #13
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Those are the Qt plugins, not the MySQL runtime libraries. You are looking for libmysqlclient.so somewhere on your system.

  14. #14
    Join Date
    Jul 2013
    Posts
    12
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Quote Originally Posted by ChrisW67 View Post
    Those are the Qt plugins, not the MySQL runtime libraries. You are looking for libmysqlclient.so somewhere on your system.
    Yeah I found them. What should I do with them?

    Qt Code:
    1. locaalex@alex-Laptop:~$ locate libmysqlclient.so
    2. /usr/lib/i386-linux-gnu/libmysqlclient.so.18
    3. /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0
    4. /usr/lib/x86_64-linux-gnu/libmysqlclient.so
    5. /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
    6. /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.0.0
    To copy to clipboard, switch view to plain text mode 

  15. #15
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Include them in your .pro. Example:
    Qt Code:
    1. INCLUDEPATH += "C:/oraclexe/app/oracle/product/11.2.0/server/oci/lib/MSVC/vc10"
    2.  
    3. LIBS += -L"C:/Qt/Los taninos-killgabio/qextserialport/build" -lqextserialportd
    To copy to clipboard, switch view to plain text mode 

  16. #16
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Quote Originally Posted by alexandrius View Post
    Yeah I found them. What should I do with them?
    Nothing , they should be in a default library search location for the system.

    What is the result when you run:
    Qt Code:
    1. $ ldd ~/Programming/Qt/5.1.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so
    To copy to clipboard, switch view to plain text mode 
    Are there any libraries reported missing? You might try this:
    Qt Code:
    1. $ objdump -x /home/chrisw/Qt5.1.0/5.1.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so | grep NEEDED
    To copy to clipboard, switch view to plain text mode 
    Does it show the same version number on the mysql related line as in your libs64 folder?
    Last edited by ChrisW67; 12th July 2013 at 21:50.

  17. The following user says thank you to ChrisW67 for this useful post:

    adutzu89 (17th December 2013)

  18. #17
    Join Date
    Jul 2011
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    I'm reviving this thread as it seems to be inactive without a answer to the problem and I was dealing with exactly the same problem for the past few days.
    (with Opensuse 12.3, x86_64).

    it seems that the compiled plugin that comes with the qt (qt-linux-opensource-5.1.0-x86_64-offline.bin) requires /usr/lib64/libmysqlclient_r.so.16 and opensuse comes with .18. So
    doing
    /usr/lib64 # ln -s libmysqlclient_r.so libmysqlclient_r.so.16

    seems to solve the problem.

    regards,

  19. The following user says thank you to artome for this useful post:

    adutzu89 (17th December 2013)

  20. #18
    Join Date
    Mar 2014
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Android

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    /usr/lib/i386-linux-gnu$ ln -s libmysqlclient_r.so libmysqlclient_r.so.16

    Fixed my problem

    Thanks,
    Selva

  21. The following user says thank you to tselvakumars for this useful post:

    martonmiklos (6th July 2014)

  22. #19
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    3
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    I have had the similar problem on Kubuntu 14.04 64 bit with the latest 5.3.1 Qt relase downloaded from the qt-project and installed to the /opt.
    The Ubuntu 14.04 ships with libmysqlclient 18 while the Qt 5.3.1 is built with 16. So the creating of a symlink like above did not solved my issue.
    Finally I have downloaded the libmysqlclient 16 from here:
    http://packages.ubuntu.com/lucid/amd...ent16/download

    And extraceted the library files to my /usr/lib/x86_64-linux-gnu folder.

  23. #20
    Join Date
    Mar 2016
    Posts
    14
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QSqlDatabase: QMYSQL driver not loaded but available

    Had the same problem => Plugin QMYSQL & QMYSQL 3 were available but couldn't load them :
    "QSqlDatabase: QMYSQL driver not loaded / QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7"

    Works for me on Windows with Qt SDK 5.6.0 (32bit version with mingw 4.9.2 32bit included) :
    - Downloaded MySQL 32bit in zip archive (mine was v5.7.11)
    - Extracted it to C:/MySQL
    - Copied "C:\Qt\QMySQL\lib\libmysql.dll" and "C:\Qt\QMySQL\lib\libmysqld.dll" to Windows/System32 (to avoid the "cannot found -llibmysql" compilation error)
    - Compile with "How to Build the QMYSQL Plugin on Windows" on http://doc.qt.io/qt-5/sql-driver.html#qmysql (my command was "qmake "INCLUDEPATH+=C:\Qt\QMySQL\include" "LIBS+=C:\Qt\QMySQL\lib\libmysql.lib" sql.pro" and "mingw32-make")
    - After compilation succeeded, copy (the freshly compiled) Qt5Sql.dll & Qt5Sqld.dll from "C:\Qt\Qt5.6.0\5.6\Src\qtbase\lib" to your application build directory
    - Restart QtCreator, that should work

Similar Threads

  1. QSqlDatabase: QMYSQL driver not loaded
    By onder in forum Newbie
    Replies: 12
    Last Post: 29th March 2017, 15:43
  2. QSqlDatabase: QMYSQL driver not loaded
    By edsonmcz in forum Qt Programming
    Replies: 7
    Last Post: 15th November 2014, 08:29
  3. Need Help:QSqlDatabase: QMYSQL driver not loaded
    By i4ba1 in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2011, 19:39
  4. QSqlDatabase: QMYSQL driver not loaded
    By lise in forum Newbie
    Replies: 3
    Last Post: 1st June 2010, 14:09
  5. Replies: 6
    Last Post: 28th April 2009, 07:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.