SSL connection error: unknown error number QMYSQL: Unable to connect
-
I am new to QT development. I am trying to connect with mysql database from the qt application but getting ssl connection error. Below is the code snippet.
#include <QCoreApplication>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>void connectToDatabase() {
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("aditya");
db.setUserName("root");
db.setPassword("aditya");
db.setPort(3306);if (!db.open()) { qDebug() << "Error: connection with database fail:" << db.lastError().text(); } else { qDebug() << "Database: connection ok"; }
}
void executeQuery() {
QSqlQuery query;
if (query.exec("SELECT * FROM Test")) {
while (query.next()) {
QString name = query.value("name").toString();
qDebug() << "Name:" << name;
}
} else {
qDebug() << "Query failed:" << query.lastError().text();
}
}int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);connectToDatabase(); //executeQuery(); return a.exec();
}
Getting below error while running the program
Error: connection with database fail: "SSL connection error: unknown error number QMYSQL: Unable to connect"
Any leads will be appreciated.
Thanks
-
Hi and welcome to devnet,
What kind of certificate are you using for that database ?
Which version of Qt are you using ?
On which OS ?
Which version of MySQL ? -
Hi and welcome to devnet,
What kind of certificate are you using for that database ?
Which version of Qt are you using ?
On which OS ?
Which version of MySQL ? -
@SGaist I do not have any certificate added as of now.
QT version: 6.5.6
OS: Windows
MySQL version: 8.0.36 -
Disable ssl on your mysql server and/or try to disable them with the appropriate connect options (but might not work when the mysql server is configured to not allow unencrypted connections).
-
Disable ssl on your mysql server and/or try to disable them with the appropriate connect options (but might not work when the mysql server is configured to not allow unencrypted connections).
@Christian-Ehrlicher I have already disabled SSL on MySQL server
-
@Aditya20 said in SSL connection error: unknown error number QMYSQL: Unable to connect:
I am still facing same issue. Any help would be appreciated
And you still did not played around with the corresponding connect options ... so no help from my side possible.
-
-