Important: Please read the Qt Code of Conduct -

QMYSQL: Unable to connect

  • Hello, I tried to connect to a MySQL Database (runs also on localhost) but I always get the Error:
    "Host 'Patrick-PC' is not allowed to connect to this MySQL server QMYSQL: Unable to connect".

    I already made a new User Account and allowed all Host connections. Also allowed all connections on the root account. Still not working.

    I also didn't find skip networking in the config file. Thus this shouldn't be the problem either...

    When using the Mysql Command Line Client everything is working.

    Some more Information, which may be useful:
    -MySQL Server 5.6 (not upgraded and no other installed)
    -QT 5.2 , IDE is QT Creator
    -Windows 7 64 bit

    I hope someone has a idea. I already searched the whole day but nothing seems to fix this problem :/
    @#include <QtWidgets/QMainWindow>
    #include "ui_MessengerServer_UI.h"
    #include <QSqlDatabase>
    #include <QSqlError>
    #include <QtSql>
    @#include "messengerserver.h"

    MessengerServer::MessengerServer(const QString &DBAddress, quint16 port,QWidget *parent)
    : QMainWindow(parent)

    //Mit Datenbank verbinden
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    bool ok =;

    if(ok == false)
    Ausgabe->append("Verbindung zur Datenbank konnte nicht hergestellt werden.\n");

Log in to reply