Results 1 to 20 of 20

Thread: QSqlDatabase: QMYSQL driver not loaded but available

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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)

Similar Threads

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