Connect to MYSQL failed in Qt
-
@SGaist I removed:
win32:CONFIG(release, debug|release): LIBS += $$PWD/lib/ -llibmysql else:win32:CONFIG(debug, debug|release): LIBS += $$PWD/lib/ -llibmysqld else:unix: LIBS += $$PWD/lib/ -llibmysql
And tried only
LIBS += -L"lib" -llibmysql
Still error:
:-1: error: error: cannot find -llibmysql
-
"Drop the lib prefix":
-lmysql
To repeat myself: Oracle does not provide pre-built binaries for Android.
Also, @Christian-Ehrlicher already asked you several times: what exact error did you get with the QtSql module ?
-
@SGaist ok its weird,it now dont give any error.But its EXCELENT!
But it unable to connect to Server
My code:QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("pos"); db.setUserName("root"); if (!db.open()){ ui->error->setText("Oops,Unable to connect to Server!Please contact your Administrator for help."); }
Includes:
#include <QtSql/QSql> #include <QtSql/QSqlDatabase> #include <QtSql/QSqlDriver> #include <QtSql/QSqlQuery>
and i also added sql to Qt in Profile
QT += core gui sql
-
@ELEMENTICY im sure i entered correct server info
-
@ELEMENTICY
So yourroot
user has no password to connect to MySQL?If
db.open()
fails, why don't you print outdb.lastError()
into your error message? -
Do you have a run time warning stating that the plugin cannot be loaded ?
-
@ELEMENTICY said in Connect to MYSQL failed in Qt:
@SGaist yes there is
Then build the plugin following the instructions from the
documentation.As I already noted: there's no prebuilt Oracle MySQL library for Androïd. You will have to build the MariaDB libraries and then the plugin for that platform.
As a side note: if you intend for your application to access that database through internet, you should reconsider that. It's a really bad idea to put a database in front of internet.