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. MYSQL connection with Qt on PC
Forum Updated to NodeBB v4.3 + New Features

MYSQL connection with Qt on PC

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 7.3k 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.
  • D Offline
    D Offline
    Devbizz
    wrote on last edited by
    #1

    Dear readers,

    for months I have been trying to get MYSQL working with Qt. This because my website's database is filled with information,
    which I would also like to use in my program i.e. my program needs access to MySQL.

    Untill today I have been unable to get a working connection, neither has anyone been willing to write a step-by-step manual on
    how to do this.

    So by this, once again, an attempt in getting someone to write me one :)

    Could someone please help me out? I am using the latest version of Qt and want to make a connection to my MySQL database
    (not local but the one that comes with my website so I have an IP address).

    I am working on a PC with Windows 7 Professional.

    Best regards

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Qt documentation offers an article about "connecting to databases":http://qt-project.org/doc/qt-4.8/sql-connecting.html Have you already read it? Do you get any errors? You might be unable to connect to your web site's database due to some administrative configuration.

      http://anavi.org/

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

        well, the problem is I dont have the MYSQL files... i am trying to make those but no matter what tutorial i use online (im on a windows 7 computer) I cant seem to get those made :(

        @#include <iostream>
        #include <QtSql/QSqlDatabase>

        using namespace std;

        int main()
        {
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("sql10.pcextreme.nl");
        db.setDatabaseName("29875cpp");
        db.setUserName("29875cpp");
        db.setPassword("cpp");
        bool ok = db.open();
        }@

        gives me the errors:

        Starting C:\Users\Ground Zero\Desktop\C++\PROJECT\project-build-desktop-Qt_4_8_1_for_Desktop_-MinGW__Qt_SDK__Debug\debug\project.exe...
        QSqlDatabase: QMYSQL driver not loaded
        QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
        QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
        C:\Users\Ground Zero\Desktop\C++\PROJECT\project-build-desktop-Qt_4_8_1_for_Desktop
        -_MinGW__Qt_SDK__Debug\debug\project.exe exited with code 0

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kunashir
          wrote on last edited by
          #4

          bq. QSqlDatabase: QMYSQL driver not loaded

          YOU have to be recompiled Qt with support for MySql or use plugin. Look in Assisten - it is greate manual for this.

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

            yeah, I cant find out how to re-compile Qt with MYSQL to...

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Devbizz
              wrote on last edited by
              #6

              When I say like:

              qmake -o Makefile "INCLUDEPATH+=c:\mysql\include" "LIBS+=Lc:\mysql\lib =lmysql" mysql.pro

              then i get three error's:

              WARNING: (internet):1: Unescaped backslashes are deprecated.

              And nothing happens, no files are made in the MYSQL folder.

              mysql is installed in c:\mysql
              When I installed mysql It did NOT create a OPT folder, but the libmysql.lib file does exist but in the
              c:\mysql\lib\ folder.

              So everything goes right untill the part where I want to make the mysql.pro file I guess.

              anyways...
              http://www.carnero.net/how-to-install-qt-mysql-driver-on-windows-7-x86-x64/

              it does make the .pro file but when I type in "nmake" it tells me the command is internally or externally not recognised.
              what can I do now?

              EDIT:

              http://qt-project.org/forums/viewthread/5790

              I followed that tutorial, all fine untill I do the following:

              qmake -o Makefile "INCLUDEPATH+=%MYSQLDIR%\include" "LIBS+=%MYSQLDIR%\lib\liblibmysql.a" mysql.pro

              I now get a screen with all kind of text and a Error 2 message... what to do !?

              !http://desmond.imageshack.us/Himg515/scaled.php?server=515&filename=69649973.png&res=landing(screen)!
              http://desmond.imageshack.us/Himg515/scaled.php?server=515&filename=69649973.png&res=landing

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Devbizz
                wrote on last edited by
                #7

                Dear readers,

                after 3 ~ 4 months, I still have not been able to get MYSQL working.
                Would someone please be so kind to help me on MSN or do it for me by using Teamviewer?

                I am willing to pay for your time.

                I am using a Windows 7 64-Bit machine (PC).

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Thanatos.jsse
                  wrote on last edited by
                  #8

                  OMG...

                  I have the same problem, currently I'm using Linux because it's easier to compile the plugin.

                  If you find the real step by step, for use QMYSQL on Windows, please tell me.

                  BR,

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kunashir
                    wrote on last edited by
                    #9

                    My use next:

                    1. All that is in the mingw-utils-0.3 to unpack in a folder with MinGW (specifically in my C: \ Qt \ 2010.05 \ mingw \ bin)
                    2. It would be nice to add that same C: \ Qt \ 2010.05 \ mingw \ bin and C: \ Qt \ 2010.05 \ qt \ bin to the PATH.
                    3. Now go to C: \ MySQL \ MySQL51 \ lib \ opt, and there do the following:
                      • reimp-d libmysql.lib
                      • dlltool-k-d libmysql.def-l libmysql.a
                    4. After that, run the build of the Qt:
                      • configure.exe-debug-and-release-platform win32-g + +-qt-sql-mysql-l mysql-IC: \ MySQL \ MySQL51 \ include-LC: \ MySQL \ MySQL51 \ lib \ opt
                      • mingw32-make sub-src
                      And the smoke for a long time ...
                      Five. After the stamp in the C: \ Qt \ 2010.05 \ Qt \ src \ plugins \ sqldrivers \ mysql and there:
                      qmake "INCLUDEPATH + = C: \ MySQL \ MySQL51 \ include" "LIBS + =-L. mysql" mysql.pro

                    If everything goes well then in C: \ Qt \ 2010.05 \ qt \ plugins \ sqldrivers should appear:
                    • libqsqlmysql4.a
                    • libqsqlmysqld4.a
                    • qsqlmysql4.dll
                    • qsqlmysqld4.dll

                    1. One last thing:
                      Copy these libraries in C: \ Qt \ ... \ qt \ plugins \ sqldrivers , as well as C: \ MySQL \ lib \ opt \ libmysql.dll in C: \ Qt \ ... \ qt \ bin.
                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #10

                      [quote author="Devbizz" date="1336572641"]Dear readers,

                      after 3 ~ 4 months, I still have not been able to get MYSQL working.
                      Would someone please be so kind to help me on MSN or do it for me by using Teamviewer?

                      I am willing to pay for your time.

                      I am using a Windows 7 64-Bit machine (PC).[/quote]

                      I have merged your two topics on the same issue. Please don't open multiple topics discussing the same problem.

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        Devbizz
                        wrote on last edited by
                        #11

                        understood Andre.
                        @ kunashir, I will try this tonight, I will let you know if it worked!

                        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