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)
    {
    setupUi(this);

    //Mit Datenbank verbinden
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("127.0.0.1");
    db.setPort(3306);
    db.setDatabaseName("secim_db");
    db.setUserName("root");
    db.setPassword("xxxx");
    bool ok = db.open();
    //===================================

    if(ok == false)
    {
    Ausgabe->append("Verbindung zur Datenbank konnte nicht hergestellt werden.\n");
    Ausgabe->append(db.lastError().text());
    }
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.