Cannot access MySQL running on another machine
-
wrote on 14 Jan 2019, 12:38 last edited by
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'") -
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'")@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? -
@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?wrote on 14 Jan 2019, 12:55 last edited by@jsulm Yes, all information used is the same
-
Hi,
As @jsulm already suggested, did you apply
mysqladmin flush-hosts
as the error message states ? -
wrote on 15 Jan 2019, 14:04 last edited by
Are you able to use something like MySQL Workbench and connect to your server instance from your remote machine?
-
Are you able to use something like MySQL Workbench and connect to your server instance from your remote machine?
wrote on 28 Jan 2019, 09:11 last edited by@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
-
@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
wrote on 28 Jan 2019, 14:19 last edited by Pablo J. Rogina@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