<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[trouble with database connection first try &#x2F; time - never before connected]]></title><description><![CDATA[<p dir="auto">Tried installed XAMPP at 3306 apache/ mysql server and also installed  from Oracle/MySQL mysql server 8.0 at 33601 and connector C++<br />
where put libmysql.dll  from Oracle MySQL server install /? what is thisa mysqlcppconn8-2-vs14.dll from connector? // tried all and maria DB but getting same message well ?</p>
<p dir="auto">Console<br />
QSqlDatabase: QMYSQL driver not loaded<br />
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7<br />
Failed to connect.<br />
Press &lt;RETURN&gt; to close this window...</p>
<p dir="auto">code  main.cpp console app ---<br />
<a href="http://DatabaseConnection.pro" target="_blank" rel="noopener noreferrer nofollow ugc">DatabaseConnection.pro</a></p>
<pre><code>QT += core sql
#QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
</code></pre>
<p dir="auto">// main.cpp</p>
<pre><code>#include &lt;QCoreApplication&gt;
#include &lt;QtSql&gt;
#include &lt;QSqlDatabase&gt;
#include &lt;QSqlQuery&gt;
#include &lt;QDebug&gt;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); // QMARIADB
    db.setHostName("127.0.0.1");
    db.setPort(33061);  // &lt;&lt;&lt; MysQL Server 8.0 |  XAMPP MySQL 3306 
    db.setDatabaseName("test");
    db.setUserName("root");
    db.setPassword("123456"); //    XAMPP Mysql empty pass  ''

    if (db.open())
    {
        qDebug() &lt;&lt; "Connected!";
    }
    else
    {
        qDebug() &lt;&lt; "Failed to connect.";
        return 0;
    }


  QString command = "SELECT my_user.username, department.name AS deptname FROM (SELECT * FROM user WHERE status = 0) AS my_user INNER JOIN department ON department.id = my_user.deptID";
    QSqlQuery query(db);
    if (query.exec(command))
    {
        while(query.next())
        {
            QString username = query.value("username").toString();
            QString department = query.value("deptname").toString();

            qDebug() &lt;&lt; username &lt;&lt; department;
        }
    }

    return a.exec();
}
</code></pre>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/b802376c-364d-400d-a8aa-d76fdce4d9a4.png" alt="0_1556618399422_2019-04-30_12-56-19 Qt forums.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/102287/trouble-with-database-connection-first-try-time-never-before-connected</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 23:41:19 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/102287.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Apr 2019 10:01:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Thu, 02 May 2019 06:50:39 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">AFAIK, no, but it has to match the architecture of your version of Qt.</p>
]]></description><link>https://forum.qt.io/post/526488</link><guid isPermaLink="true">https://forum.qt.io/post/526488</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 02 May 2019 06:50:39 GMT</pubDate></item><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Thu, 02 May 2019 05:36:38 GMT]]></title><description><![CDATA[<p dir="auto">driver connector -C dll mysql or mariadb<br />
either 32-bit or 64-bit this (the x-bit) must match the y-bit of mysql installation ???</p>
<p dir="auto">In other words 64-bit MySQL installation  REQUIRES 64-bit connector-C++ ... ?</p>
]]></description><link>https://forum.qt.io/post/526476</link><guid isPermaLink="true">https://forum.qt.io/post/526476</guid><dc:creator><![CDATA[lse123]]></dc:creator><pubDate>Thu, 02 May 2019 05:36:38 GMT</pubDate></item><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Wed, 01 May 2019 03:43:13 GMT]]></title><description><![CDATA[<p dir="auto">yes SOLVED<br />
how mark this as SOLVED ??????  OK FOUND IT</p>
]]></description><link>https://forum.qt.io/post/526279</link><guid isPermaLink="true">https://forum.qt.io/post/526279</guid><dc:creator><![CDATA[lse123]]></dc:creator><pubDate>Wed, 01 May 2019 03:43:13 GMT</pubDate></item><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Tue, 30 Apr 2019 12:06:02 GMT]]></title><description><![CDATA[<p dir="auto">if you solved the problem please mark this topic as solved - in order for others to know that this has been sorted out...</p>
]]></description><link>https://forum.qt.io/post/526135</link><guid isPermaLink="true">https://forum.qt.io/post/526135</guid><dc:creator><![CDATA[arsinte_andrei]]></dc:creator><pubDate>Tue, 30 Apr 2019 12:06:02 GMT</pubDate></item><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Tue, 30 Apr 2019 11:45:57 GMT]]></title><description><![CDATA[<p dir="auto">C:\Qt\5.12.2\msvc2017_64\bin\</p>
<p dir="auto">^^^ put here<br />
started  XAMPP</p>
<p dir="auto">connected !!!!<br />
<img src="https://ddgobkiprc33d.cloudfront.net/f9268fb3-f13f-4fb5-9785-7310e8ae255f.png" alt="0_1556624435005_2019-04-30_14-38-36 64 connected.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/f870084e-85f4-432e-be50-bb1b20b779f3.png" alt="0_1556624743379_2019-04-30_14-45-02 qt result.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/526128</link><guid isPermaLink="true">https://forum.qt.io/post/526128</guid><dc:creator><![CDATA[lse123]]></dc:creator><pubDate>Tue, 30 Apr 2019 11:45:57 GMT</pubDate></item><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Tue, 30 Apr 2019 11:33:31 GMT]]></title><description><![CDATA[<p dir="auto">see and above</p>
<p dir="auto">what is the correct directory to put the dll???  this C:\Qt\5.12.2\msvc2017\bin\ or in the app build itself... ?</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/e41f2fdd-18d3-46c5-a93f-988541ac9b81.png" alt="0_1556623684753_2019-04-30_14-27-16 powershell.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/526125</link><guid isPermaLink="true">https://forum.qt.io/post/526125</guid><dc:creator><![CDATA[lse123]]></dc:creator><pubDate>Tue, 30 Apr 2019 11:33:31 GMT</pubDate></item><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Tue, 30 Apr 2019 11:24:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/lse123">@<bdi>lse123</bdi></a> said in <a href="/post/526102">trouble with database connection first try / time - never before connected</a>:</p>
<blockquote>
<p dir="auto">libmysql.dll  from Oracle MySQL server install /? what is thisa mysqlcppconn8-2-vs14.dll</p>
</blockquote>
<p dir="auto">I have to put this<br />
libmysql.dll<br />
or this<br />
mysqlcppconn8-2-vs14.dll<br />
or<br />
libmariadb.dll</p>
<p dir="auto">in the right directory? 32-bit vs 64-bit driver connector depends only from mysql installation or and from Qt app if 32/64 [for xampp choose 32-bit connector???]???<br />
for connection with XAMPP apache / mysql ???</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/2399541a-66af-47ca-97b9-31334ad186eb.png" alt="0_1556623291489_2019-04-30_14-18-59 phpmyadmin.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/526123</link><guid isPermaLink="true">https://forum.qt.io/post/526123</guid><dc:creator><![CDATA[lse123]]></dc:creator><pubDate>Tue, 30 Apr 2019 11:24:24 GMT</pubDate></item><item><title><![CDATA[Reply to trouble with database connection first try &#x2F; time - never before connected on Tue, 30 Apr 2019 10:08:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/lse123">@<bdi>lse123</bdi></a> said in <a href="/post/526102">trouble with database connection first try / time - never before connected</a>:</p>
<blockquote>
<p dir="auto">Console<br />
QSqlDatabase: QMYSQL driver not loaded<br />
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7<br />
Failed to connect.<br />
Press &lt;RETURN&gt; to close this window...</p>
</blockquote>
<p dir="auto">that means that the Mysql dll is not loaded or is missing - Qt cannot find the library to load MySQL - is just a mater of loading /finding the dll and put it in the right director -sorry I'm a Linux user I do not know on windows but you can google it</p>
<p dir="auto"><a href="https://duckduckgo.com/?q=QSqlDatabase%3A+QMYSQL+driver+not+loaded&amp;t=canonical&amp;atb=v137-1&amp;ia=web" target="_blank" rel="noopener noreferrer nofollow ugc">https://duckduckgo.com/?q=QSqlDatabase%3A+QMYSQL+driver+not+loaded&amp;t=canonical&amp;atb=v137-1&amp;ia=web</a></p>
]]></description><link>https://forum.qt.io/post/526104</link><guid isPermaLink="true">https://forum.qt.io/post/526104</guid><dc:creator><![CDATA[arsinte_andrei]]></dc:creator><pubDate>Tue, 30 Apr 2019 10:08:17 GMT</pubDate></item></channel></rss>