QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL","mydb"); db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1"); db.setDatabaseName(mydatabase); db.setHostName(serverHost); db.setUserName(mylogin); db.setPassword(mypassword); if (db.open()){ qDebug() << "db connection OK"; }else{ qDebug() << "db connection FALSE"; exit(0); }