Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connect Qt to MySQL
Qt 6.11 is out! See what's new in the release blog

Connect Qt to MySQL

Scheduled Pinned Locked Moved Unsolved General and Desktop
25 Posts 5 Posters 21.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.
  • jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #10

    Try with:

    set mysql="C:\Program Files\MySQL\MySQL Server 5.7"
    

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #11
      This post is deleted!
      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #12

        It give me :

        Cannot find file: Files\MySQL\MySQL.
        Cannot find file: Server.
        Cannot find file: 5.7\include.
        Cannot find file: Files\MySQL\MySQL.
        Cannot find file: Server.
        Cannot find file: 5.7\lib\libmysql.lib.
        Cannot find file: mysql.pro.
        

        I don't understand the line "Mysql.h : no such file or directory" in the error text, there is in fact a file named mysql.h in my folder "MySQL server 5.7\include"

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

          Hi,

          The best thing to do is to move your MySQL installation in a folder without any space in the path. Or use the 8.3 notation.

          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
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #14

            I did it, it resolved my first error, but it gives me a new one :

            My lines :

            cd C:\qt-everywhere-opensource-src-5.6.0\qtbase\src\plugins\sqldrivers\mysql
            set mysql=C:\MySQL\MySQL_Server_5.7
            qmake "INCLUDEPATH+=%mysql%\include" "LIBS+=%mysql%\lib\libmysql.lib" mysql.pro
            mingw32-make
            

            And the error :

            mingw32-make[1]: Entering directory 'C:/qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/sqldrivers/mysql'
            g++ -Wl,-s -shared -Wl,-subsystem,windows -Wl,--out-implib,C:\qt-everywhere-opensource-src-5.6.0\qtbase\plugins\sqldrivers\libqsqlmysql.a -o ..\..\..\..\plugins\sqldrivers\qsqlmysql.dll .obj/release/main.o .obj/release/qsql_mysql.o .obj/release/moc_qsql_mysql_p.o  C:\MySQL\MySQL_Server_5.7\lib\libmysql.lib -LC:/Qt/5.4/mingw491_32/lib -lQt5Sql542 -lQt5Core542 .obj\release\qsqlmysql_resource_res.o
            C:/Qt/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Sql542
            C:/Qt/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Core542
            collect2.exe: error: ld returned 1 exit status
            Makefile.Release:81: recipe for target '..\..\..\..\plugins\sqldrivers\qsqlmysql.dll' failed
            mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlmysql.dll] Error 1
            mingw32-make[1]: Leaving directory 'C:/qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/sqldrivers/mysql'
            makefile:38: recipe for target 'release-all' failed
            mingw32-make: *** [release-all] Error 2
            Appuyez sur une touche pour continuer...
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #15

              Looks like you are trying to build the Qt 5.6.0 sources with Qt 5.4.2 ?

              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
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #16

                Yes, I was, so I reinstall Qt 5.6, finally, and I get a (last?) error : The compiler is MSVC 2015, but at the line "nmake", i get a invalid command error
                So I tried to call vcvarsall.bat, but I doesn't not change anything
                (Yes i'm really a beginner)

                1 Reply Last reply
                0
                • jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #17

                  In your previous post I see: mingw32-make
                  That means you was using MinGW. Did you switch to MSVC2015?
                  Did you rerun qmake?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                    Yes I have, I desinstalled Qt 5.5, and reinstall Qt 5.6, and now the Qt console is name MSVC 2015, but it don't recognized the line "nmake"...
                    Yes I rerun qmake

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

                      Open a Visual Studio developer console, that will make thing easier. IIRC it should be in one of the subfolder of the Visual Studio Start menu entry.

                      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
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #20

                        I did it : qmake become invalid command, how do I set environnement to avoid it ?

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

                          Either use the full path to qmake or go to the Qt folder and IIRC there's a qtvars.bat file to setup the paths needed.

                          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
                          • ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #22

                            Ok perfect, I finally made it, but I don't understand where I have to put the dll to run a project with MySQL ?

                            cfdevC 1 Reply Last reply
                            0
                            • ? A Former User

                              Ok perfect, I finally made it, but I don't understand where I have to put the dll to run a project with MySQL ?

                              cfdevC Offline
                              cfdevC Offline
                              cfdev
                              wrote on last edited by
                              #23

                              @Detordreur like all sql plugin -> /sqldrivers

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

                                This is what i've done, in the folder of the executable, but when I try to compile this gives me :
                                (10061) QMYSQL : Unable to connect

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

                                  Isn't it rather when you run your application ?

                                  If it can't connect, did you check your network settings ? Is your database running ?

                                  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
                                  • Unsolved