Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    [Solved] New Qt install and MySql

    Installation and Deployment
    2
    9
    2551
    Loading More Posts
    • 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.
    • M
      mattj last edited by mattj

      Hi all,

      I need some help getting MySQL running with my Qt server application. There are lots of other posts/search results for this, but I have what may be basic questions that never seem to be answered.

      My setup:

      Linux Mint
      Qt 5.4 (open source/community) installed from website to /home/matt/Qt
      MySql Server 5.5 installed from repo

      I'm trying to build a client/server application. While developing, the client, server and mysql server will all run on the same machine. When deployed all 3 can and will be running on different machines (client on Windows, server and mysql server on Linux).

      According to "this page":http://doc.qt.io/qt-5/sql-driver.html#qmysql: Qt comes packaged with a driver for mysql and there is a file called libsqlmysql.so in this location:

      /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/

      But the page also says 'not all of the plugins are provided with Open Source Versions of Qt'. So which drivers aren't? I've tried to connect to my mysql database but get the following error:

      @QSqlDatabase: QMYSQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7@

      using this code:

      @ QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
      db.setDatabaseName("mydb");
      db.setHostName("localhost");
      db.setUserName("dbuser");
      db.setPassword("dbuserpwd");@

      Do I need to build the driver for mysql for my setup?
      What are the actual requirements for getting this to work with my development setup (i.e. 1 machine) and later on with the server app and database server running on different machines?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Do you have the MySQL client libraries installed on your machine ?

        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 Reply Quote 0
        • M
          mattj last edited by

          Hi SGAist, thanks for your reply. I'm not sure if the client libraries are installed - what are they?

          I have mysql-client and mysql-server installed, and apt-get offers these other options for mysql*:

          mysql-client
          mysql-mmm-agent
          mysql-proxy
          mysql-source-5.5
          mysqltuner
          mysql-client-5.5
          mysql-mmm-common
          mysql-server
          mysqltcl
          mysql-utilities
          mysql-client-core-5.5
          mysql-mmm-monitor
          mysql-server-5.5
          mysql-testsuite
          mysql-workbench
          mysql-common
          mysql-mmm-tools
          mysql-server-core-5.5
          mysql-testsuite-5.5
          mysql-workbench-data

          Thanks again,
          Matt

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Ok, then run ldd on the plugin to check if everything it needs can be found

            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 Reply Quote 0
            • M
              mattj last edited by

              Do you mean this file:

              @/home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/libsqlmysql.so@

              If so, this is the ldd output:

              @linux-vdso.so.1 => (0x00007fff6bda5000)
              libmysqlclient_r.so.16 => not found
              libQt5Sql.so.5 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fd0a85db000)
              libQt5Core.so.5 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fd0a7e9e000)
              libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd0a7b9a000)
              libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd0a77d2000)
              libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd0a75b4000)
              libicui18n.so.53 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.53 (0x00007fd0a7168000)
              libicuuc.so.53 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.53 (0x00007fd0a6ddd000)
              libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd0a6bd8000)
              libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fd0a69d6000)
              librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd0a67ce000)
              libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fd0a64cc000)
              libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd0a61c8000)
              libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd0a5fb2000)
              /lib64/ld-linux-x86-64.so.2 (0x00007fd0a8a4a000)
              libicudata.so.53 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.53 (0x00007fd0a4929000)
              libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fd0a46ea000)@

              I'm guessing this is the problem?

              @libmysqlclient_r.so.16 => not found@

              But I have no idea why, or how to fix it!

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                You probably have libmysqlclient_r.so.16 on your system so you can either try to get version 16 installed or rebuild the plugin to use your currently installed library version

                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 Reply Quote 0
                • M
                  mattj last edited by

                  OK, thanks. In this context are 'plugin' and 'driver' the same thing? In both cases is it this file:

                  /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/libsqlmysql.so ?

                  And this file plugin/driver (that came with my install of Qt) has been built with version 16?

                  I will try to build it using the instructions "here":http://qt-project.org/doc/qt-4.8/sql-driver.html#qmysql

                  1 Reply Last reply Reply Quote 0
                  • M
                    mattj last edited by

                    Thanks SGaist, that got it working - it turned out I had version 18.

                    One thing I didn't find too clear in the instructions was what the 'INCLUDEPATH' should be so left it as:

                    @"INCLUDEPATH+=/usr/local/include"@

                    It seemed to work even though there is nothing in that folder on my system.

                    How does Qt/my application know where to look for the driver? When I move the server application to a new system where should the driver go?

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      That's because you have a distribution installed MySQL which put dev package content in common places.

                      It's built in the library, if you take a look at the folder structure of Qt you'll see how it works..

                      How do you plan to distribute your application ??

                      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 Reply Quote 0
                      • First post
                        Last post