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. Cannot access MySQL running on another machine
QtWS25 Last Chance

Cannot access MySQL running on another machine

Scheduled Pinned Locked Moved Solved General and Desktop
mysqltcpsql
7 Posts 5 Posters 1.9k Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 14 Jan 2019, 12:38 last edited by
    #1

    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'")

    J 1 Reply Last reply 14 Jan 2019, 12:48
    0
    • ? A Former User
      14 Jan 2019, 12:38

      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'")

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 14 Jan 2019, 12:48 last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      ? 1 Reply Last reply 14 Jan 2019, 12:55
      1
      • J jsulm
        14 Jan 2019, 12:48

        @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?

        ? Offline
        ? Offline
        A Former User
        wrote on 14 Jan 2019, 12:55 last edited by
        #3

        @jsulm Yes, all information used is the same

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 14 Jan 2019, 21:27 last edited by
          #4

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MrShawn
            wrote on 15 Jan 2019, 14:04 last edited by
            #5

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

            ? 1 Reply Last reply 28 Jan 2019, 09:11
            0
            • M MrShawn
              15 Jan 2019, 14:04

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

              ? Offline
              ? Offline
              A Former User
              wrote on 28 Jan 2019, 09:11 last edited by
              #6

              @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

              P 1 Reply Last reply 28 Jan 2019, 14:19
              0
              • ? A Former User
                28 Jan 2019, 09:11

                @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

                P Offline
                P Offline
                Pablo J. Rogina
                wrote on 28 Jan 2019, 14:19 last edited by Pablo J. Rogina
                #7

                @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

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved