Unsolved How to connect to mysql
-
I tried to search for solutions but so far none have worked. I'm using windows 10.
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("127.0.0.1");
db.setUserName("root");
db.setPassword("");
db.setDatabaseName("slmp");if (db.open()) ui->db_label->setText("Connected..."); else { ui->db_label->setText("Failed to connect"); }
When i try to run this code it fails to connect because mysql driver isn't loaded. I looked up how to fix this and it says to download mysql connector. I downloaded the c++ 8.0.15 win 32 connector. 1st I added the vs14 file through the add library function but that failed. Then I pasted the libeay32.dll and the other dll files that comes with it in the mscv2015_64 and that failed. I also tried pasting the dll files in mscv2017, mscv2017_64, mingw73_64 all lead to failures.
-
Hello @Mocha-Shakea-Khan and welcome to Qt Forum.
Have you tried this fixed post ?
https://forum.qt.io/topic/40672/how-to-create-the-plugin-of-mysql-for-qt