From 10:00 CET Friday 22nd November we will adjust how the server works to deal with some recently reported problems. Therefore there may be a load problem, if you experience more problems than usual trying to access the forum then please PM AndyS or any of the moderators so they can inform me.


Cannot access MySQL running on another machine



  • Hello,
    I've been trying to connect to a local server (NOT localhost). No matter what I do the connection always fails and I'm uncertain why.
    However, it is possible to connect to it using other tools that utilize a TCP/IP connection.
    I was wondering if there's a solution or TCP driver available for Qt somewhere?

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName(ip);
        db.setPort(3306);
        db.setUserName(user_name);
        db.setPassword(pw);
        db.setDatabaseName(db_name);
    
        if(db.open())
        {
            QMessageBox::information(this, "Connection Status", "Connection Successful!");
            query = new QSqlTableModel();
            query->setQuery(ui->lineEdit_query->text());
            ui->tableView->setModel(query);
            qDebug() << db.userName();
        }
        else
        {
            QMessageBox::information(this, "Connection Status", "Connection Failed!\n" + db.hostName() + ":" + QString::number(db.port()));
            qDebug() << db.lastError();
        }
    

    qDebug has been throwing an Access denied error. So I assume there must have been a sort of communication between the MySQL server and my application.
    Meanwhile I get this error: ```
    QSqlError("1129", "QMYSQL: Unable to connect", "Host '10.141.***' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'")


  • Qt Champions 2018

    @SnuggleKat said in Cannot access MySQL running on another machine:

    "Host '10.141.***' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'")

    You will first need to do what the error suggests to be able to connect.
    Do you use exact same data (user name, password, ip, port) to connect as you do when using other tools?



  • @jsulm Yes, all information used is the same


  • Lifetime Qt Champion

    Hi,

    As @jsulm already suggested, did you apply mysqladmin flush-hosts as the error message states ?



  • Are you able to use something like MySQL Workbench and connect to your server instance from your remote machine?



  • @MrShawn said in Cannot access MySQL running on another machine:

    Are you able to use something like MySQL Workbench and connect to your server instance from your remote machine?

    Yes. Tried some setting in the my.cnf. Looks like skip-networking solved the problem



  • @SnuggleKat said in Cannot access MySQL running on another machine:

    Looks like skip-networking solved the problem

    Could you describe what this skip-networking concept is? for the sake of completeness and benefit of documenting the case for other future users having the same issue.

    And if your issue is solved, please don't forget to mark your post as such. Thanks


Log in to reply