Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMYSQL: Unable to connect
Forum Updated to NodeBB v4.3 + New Features

QMYSQL: Unable to connect

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k 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.
  • D Offline
    D Offline
    Dex2121
    wrote on last edited by
    #1

    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());
    }
    }
    @

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