Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QMYSQL driver not loaded on Ubuntu
-
Hello everybody i get and installed Qt 5.2 x64 edition for Linux ubuntu.
I have QTPLUGIN += qsqlmysql and QT += sql in file .pro
and libqsqlmysql.so plugin is in /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers folder but after run show me errors...
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QSQLITE2 QPSQL7 QPSQLwhy ? how I can fix this error?
-
Hi,
Do you also have the MySql libraries installed on your OS ?
-
Yes !
root@Gigabyte-Z68P-DS3:~# dpkg --list|grep mysql
ii libmysql++-dev 3.1.0-2 amd64 MySQL C++ library bindings (development)
ii libmysql++3 3.1.0-2 amd64 MySQL C++ library bindings (runtime)
ii libmysqlclient-dev 5.5.34-0ubuntu0.13.10.1 amd64 MySQL database development files
ii libmysqlclient18:amd64 5.5.34-0ubuntu0.13.10.1 amd64 MySQL database client library
ii libmysqlclient18:i386 5.5.34-0ubuntu0.13.10.1 i386 MySQL database client library
ii libmysqlcppconn-dev 1.1.3-3 amd64 MySQL Connector for C++ (development files)
ii libmysqlcppconn7 1.1.3-3 amd64 MySQL Connector for C++ (library)
ii libqt4-sql-mysql:amd64 4:4.8.4+dfsg-0ubuntu18.1 amd64 Qt 4 MySQL database driver
ii libqt4-sql-mysql:i386 4:4.8.4+dfsg-0ubuntu18.1 i386 Qt 4 MySQL database driver
ii libqt5sql5-mysql:amd64 5.0.2+dfsg1-7ubuntu11.1 amd64 Qt 5 MySQL database driver
ii mysql-common 5.5.34-0ubuntu0.13.10.1 all MySQL database common files, e.g. /etc/mysql/my.cnf
-
And what do you get if your run ldd on Qt's mysql plugin ?
-
I don't understand ! I,m new on Qt ...
Of course I use XAMPP for testing MySQL Database.my code for test on console app :
@
#include <QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql>
#include <QDebug>//remplacer l'affichage par la commande cout
#define q2c(string) string.toStdString()int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); // This is the line I got error db.setHostName("localhost"); db.setDatabaseName("qtdatabase"); db.setUserName("root"); db.setPassword(""); bool ok = db.open(); return a.exec();
}
@
return this errors :
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QSQLITE2 QMYSQL QMYSQL3 QPSQL7 QPSQLbut with this code :
@
#include <QCoreApplication>
#include <QtSql/qsql.h>
#include <QtSql/qsqldatabase.h>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>
#include <QDebug>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QStringList drivers = QSqlDatabase::drivers(); for(int i = 0; i < drivers.count(); i++) qDebug() << drivers.at(i); return a.exec();
}
@
return this output:
"QMYSQL","QMYSQL3" and ...
-
Qt's MySql plugin is call libqsqlmysql.so, call ldd on it and check that it can find all dependencies
-
[quote author="SGaist" date="1388524196"]Qt's MySql plugin is call libqsqlmysql.so, call ldd on it and check that it can find all dependencies[/quote]
what is your mean of ldd ? I have libqsqlmysql.so file in below address :
/opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers
-
ldd is a little utility that lists the dependencies of an executable/dynamic library
-
[quote author="SGaist" date="1388526680"]ldd is a little utility that lists the dependencies of an executable/dynamic library[/quote]
How can I check this option ? This is installed utility on OS or Qt ?
Please give me more information about this.
How to call ldd?I now install Qt on Windows for check my problem but now show error for load..
Qt_5_2_0_MinGW_32bit edition:
Starting C:\Users\Kambiz\Documents\Qt\build-untitled16-Desktop_Qt_5_2_0_MinGW_32bit-Debug\debug\untitled16.exe...
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
C:\Users\Kambiz\Documents\Qt\build-untitled16-Desktop_Qt_5_2_0_MinGW_32bit-Debug\debug\untitled16.exe exited with code 0Qt_5_2_0_MSVC2012_64bit edition:
Starting C:\Users\Kambiz\Documents\Qt\build-untitled15-Desktop_Qt_5_2_0_MSVC2012_64bit-Debug\debug\untitled15.exe...
QSqlDatabase: QMYSQL driver not loaded
-
"here":http://bit.ly/1l2bNYY
Did you install MySQL on Windows ? Do you have the MySql dll somewhere accessible in your PATH ?
-
[quote author="SGaist" date="1388613736"]"here":http://bit.ly/1l2bNYY
Did you install MySQL on Windows ? Do you have the MySql dll somewhere accessible in your PATH ?[/quote]
Yes I have it on below path :
C:\Program Files\MySQL\MySQL Server 5.6
and
C:\Program Files (X86) \MySQL\MySQL Server 5.6and on Linux ubuntu too
On Windows I use of qt-windows-opensource-5.2.0-mingw48_opengl-x86-offline.exe and qt-windows-opensource-5.2.0-msvc2012-x86_64-offline.exe
but I don't know why doesn't work :(
-
You didn't answer the questions:
What does ldd return ?Is the MySql dll folder in your PATH variable ? Or at least in the PATH environment variable in the run section of the Project panel in Qt Creator ?
-
For Windows...
MySql dll folder :
I have libmysql.dll and libmysql.lib and mysqlclient.lib here C:\Program Files\MySQL\MySQL Server 5.6\liband I have qsqlmysql.dll and qsqlmysqld.dll and other files in here :
C:\Qt\Qt5.2.0-MG\5.2.0\mingw48_32\plugins\sqldrivers
and
C:\Qt\Qt5.2.0\5.2.0\msvc2012_64\plugins\sqldrivers
-
and For Linux about ldd :
root@Gigabyte-Z68P-DS3:~# ldd /bin/date
linux-vdso.so.1 => (0x00007fff31d72000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0ea438c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ea3fc4000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0ea3da6000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0ea45b5000)and about MySQL plugin folder and files:
in here :
/opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers .... I have libqsqlmysql.so
-
I know where your dlls are. If using 64bit, the question is: is "C:\Program Files\MySQL\MySQL Server 5.6\lib" contained in the PATH environment variable in the Run section on the Project panel in Qt Creator ?
I didn't ask you to run ldd on /bin/date but on your Qt 5.2.0 libqsqlmysql.so
-
[quote author="SGaist" date="1388785738"]I know where your dlls are. If using 64bit, the question is: is "C:\Program Files\MySQL\MySQL Server 5.6\lib" contained in the PATH environment variable in the Run section on the Project panel in Qt Creator ?
[/quote]OMG! NO...
Sorry ! I forget PATH environment variable !!! now my problem is sloved on Windows by add PATH environment variable for Mysql :)but for linux ?! can you give me more information ?
-
You already have all the information: call "ldd /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so"
to see what libraries it links to
-
[quote author="SGaist" date="1388788157"]You already have all the information: call "ldd /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so"
to see what libraries it links to[/quote]
This is :
root@Gigabyte-Z68P-DS3:~# ldd /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so
linux-vdso.so.1 => (0x00007fff2c89b000)
libmysqlclient_r.so.16 => not found
libQt5Sql.so.5 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libQt5Sql.so.5 (0x00007f23cac7a000)
libQt5Core.so.5 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libQt5Core.so.5 (0x00007f23ca5ac000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f23ca2a8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f23c9ee0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f23c9cc2000)
libicui18n.so.51 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libicui18n.so.51 (0x00007f23c98a9000)
libicuuc.so.51 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libicuuc.so.51 (0x00007f23c9523000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f23c931e000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f23c911c000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f23c8f14000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f23c8c12000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f23c890e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f23c86f8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f23cb0ec000)
libicudata.so.51 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libicudata.so.51 (0x00007f23c6fae000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f23c6d6f000)
root@Gigabyte-Z68P-DS3:~#
-
You have it on the second line:
@libmysqlclient_r.so.16 => not found@
Check what version number of libmysqlclient_r you have installed
-
[quote author="SGaist" date="1388870467"]You have it on the second line:
@libmysqlclient_r.so.16 => not found@
Check what version number of libmysqlclient_r you have installed[/quote]
root@Gigabyte-Z68P-DS3:~# dpkg --get-selections | grep mysql
libmysql++-dev install
libmysql++3 install
libmysqlclient-dev install
libmysqlclient18:amd64 install
libmysqlclient18:i386 install
libmysqlcppconn-dev install
libmysqlcppconn7 install
libqt4-sql-mysql:amd64 install
libqt4-sql-mysql:i386 install
libqt5sql5-mysql:amd64 install
mysql-client-core-5.5 install
mysql-common install
root@Gigabyte-Z68P-DS3:~#
-
You have the version 18 and not the 16.
So two solutions here:
- find the version 16
- build the Qt MySQL plugin yourself with this version of the client library (best)
-
[quote author="SGaist" date="1388875572"]You have the version 18 and not the 16.
So two solutions here:
find the version 16
build the Qt MySQL plugin yourself with this version of the client library (best)[/quote]
Sorry , but can you help me for find or build qt mysql plugin ?
I run this command : root@Gigabyte-Z68P-DS3:/opt/Qt5.2.0/5.2.0/Src/qtbase/src/plugins/sqldrivers/mysql# qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.proI think my command is not true ! in QT 5.2 any folders and roots is different...
-
did you call make after that ?
-
I run first this command : root@Gigabyte-Z68P-DS3:~# cd /opt/Qt5.2.0/5.2.0/Src/qtbase/src/plugins/sqldrivers/mysql
after :
root@Gigabyte-Z68P-DS3:/opt/Qt5.2.0/5.2.0/Src/qtbase/src/plugins/sqldrivers/mysql# qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
qmake: could not find a Qt installation of ''
root@Gigabyte-Z68P-DS3:/opt/Qt5.2.0/5.2.0/Src/qtbase/src/plugins/sqldrivers/mysql#
-
Are you sure you are using the right qmake ?
Also, why are you developing as root ?
-
[quote author="SGaist" date="1388958771"]Are you sure you are using the right qmake ?
Also, why are you developing as root ?[/quote]
I,m not sure ! for this reason I need to help. :D
-
what does qmake --version and which qmake return ?
-
[quote author="SGaist" date="1389045618"]what does qmake --version and which qmake return ?[/quote]
root@Gigabyte-Z68P-DS3:~# dpkg --get-selections | grep qmake
qt5-qmake installand return : qmake: could not find a Qt installation of ''
-
Check what other Qt 5 package you have installed
-
Please see this :
root@Gigabyte-Z68P-DS3:~# dpkg --get-selections | grep qt
appmenu-qt install
appmenu-qt5 install
checkbox-qt install
libaccounts-qt5-1 install
libdbusmenu-qt2:amd64 install
libdbusmenu-qt2:i386 install
libdbusmenu-qt5:amd64 install
libqt4-dbus:amd64 install
libqt4-dbus:i386 install
libqt4-declarative:amd64 install
libqt4-declarative:i386 install
libqt4-designer:amd64 install
libqt4-help:amd64 install
libqt4-network:amd64 install
libqt4-network:i386 install
libqt4-opengl:amd64 install
libqt4-opengl:i386 install
libqt4-script:amd64 install
libqt4-script:i386 install
libqt4-scripttools:amd64 install
libqt4-sql:amd64 install
libqt4-sql:i386 install
libqt4-sql-mysql:amd64 install
libqt4-sql-mysql:i386 install
libqt4-sql-sqlite:amd64 install
libqt4-svg:amd64 install
libqt4-test:amd64 install
libqt4-webkit install
libqt4-xml:amd64 install
libqt4-xml:i386 install
libqt4-xmlpatterns:amd64 install
libqt4-xmlpatterns:i386 install
libqt53d5:amd64 install
libqt5core5:amd64 install
libqt5dbus5:amd64 install
libqt5gui5:amd64 install
libqt5location5:amd64 install
libqt5network5:amd64 install
libqt5opengl5:amd64 install
libqt5printsupport5:amd64 install
libqt5qml5:amd64 install
libqt5quick5:amd64 install
libqt5sensors5:amd64 install
libqt5sql5:amd64 install
libqt5sql5-mysql:amd64 install
libqt5sql5-sqlite:amd64 install
libqt5test5:amd64 install
libqt5v8-5:amd64 install
libqt5webkit5:amd64 install
libqt5widgets5:amd64 install
libqt5xml5:amd64 install
libqtassistantclient4:amd64 install
libqtcore4:amd64 install
libqtcore4:i386 install
libqtgui4:amd64 install
libqtgui4:i386 install
libqtwebkit4:amd64 install
libqtwebkit4:i386 install
libsignon-qt5-1 install
python-qt4 install
python-qt4-dbus install
qt-at-spi:amd64 install
qt5-qmake install
qtchooser install
sni-qt:amd64 install
sni-qt:i386 install
ubuntu-sso-client-qt install
ubuntuone-control-panel-qt install
root@Gigabyte-Z68P-DS3:~#
-
Do you also have the dev package installed ?
-
here :
root@Gigabyte-Z68P-DS3:~# dpkg --get-selections | grep dev
comerr-dev install
dpkg-dev install
freeglut3-dev:amd64 install
gir1.2-gudev-1.0 install
krb5-multidev install
libalut-dev install
libasprintf-dev:amd64 install
libboost1.53-dev:amd64 install
libc-dev-bin install
libc6-dev:amd64 install
libdevmapper-event1.02.1:amd64 install
libdevmapper1.02.1:amd64 install
libdrm-dev:amd64 install
libfreetype6-dev install
libgcc-4.8-dev:amd64 install
libgettextpo-dev:amd64 install
libgfortran-4.8-dev:amd64 install
libgl1-mesa-dev install
libgl2ps-dev install
libglu1-mesa-dev install
libgudev-1.0-0:amd64 install
libice-dev:amd64 install
libimobiledevice4 install
libkrb5-dev install
libmtdev1:amd64 install
libmysql++-dev install
libmysqlclient-dev install
libmysqlcppconn-dev install
libopenal-dev:amd64 install
libpcre3-dev:amd64 install
libpthread-stubs0-dev:amd64 install
libroot-core-dev install
libroot-geom-dev install
libroot-graf2d-gpad-dev install
libroot-graf2d-graf-dev install
libroot-graf3d-gl-dev install
libroot-gui-dev install
libroot-hist-dev install
libroot-io-dev install
libroot-math-mathcore-dev install
libroot-math-matrix-dev install
libroot-net-dev install
libroot-proof-dev install
libroot-tree-dev install
libsm-dev:amd64 install
libssl-dev:amd64 install
libstdc++-4.8-dev:amd64 install
libudev1:amd64 install
libudev1:i386 install
libv4l-dev:amd64 install
libx11-dev:amd64 install
libx11-xcb-dev install
libxau-dev:amd64 install
libxcb-dri2-0-dev:amd64 install
libxcb-glx0-dev:amd64 install
libxcb1-dev:amd64 install
libxdamage-dev:amd64 install
libxdmcp-dev:amd64 install
libxext-dev:amd64 install
libxfixes-dev:amd64 install
libxpm-dev:amd64 install
libxt-dev:amd64 install
libxxf86vm-dev:amd64 install
linux-libc-dev:amd64 install
makedev install
manpages-dev install
mesa-common-dev install
python-dbus-dev install
system-config-printer-udev install
udev install
unity-scope-devhelp install
x11proto-core-dev install
x11proto-damage-dev install
x11proto-dri2-dev install
x11proto-fixes-dev install
x11proto-gl-dev install
x11proto-input-dev install
x11proto-kb-dev install
x11proto-xext-dev install
x11proto-xf86vidmode-dev install
xserver-xorg-input-evdev install
xserver-xorg-video-fbdev install
xtrans-dev install
zlib1g-dev:amd64 install
root@Gigabyte-Z68P-DS3:~#
-
I don't see any Qt related dev package
-
How can I install Qt related dev package ?
-
IIRC you can install qt5-default then the same qt5 packages with a trailing -dev in the name
-
See now i installed qt dev package :
...
...
qtbase5-dev:amd64 install
qtbase5-dev-tools install
qtdeclarative5-dev installCheck latest lines...
root@Gigabyte-Z68P-DS3:~# aptitude show qt5-default
Package: qt5-default
State: installed
Automatically installed: no
Multi-Arch: same
Version: 5.0.2+dfsg1-7ubuntu11.1
Priority: optional
Section: libs
Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com
Architecture: amd64
Uncompressed Size: 93.2 k
Depends: qtbase5-dev, qtchooser
Suggests: qt5-qmake, qtbase5-dev-tools
Conflicts: qt4-default, qt4-default
Breaks: qt5-default (!= 5.0.2+dfsg1-7ubuntu11.1)
Replaces: qt5-default (< 5.0.2+dfsg1-7ubuntu11.1)
Provides: qt-default
Description: Qt 5 development defaults package
Qt is a cross-platform C++ application framework. Qt's primary feature is its rich set of widgets
that provide standard GUI functionality.This package sets Qt 5 to be the default Qt version to be used when using development binaries like
qmake. It provides a default configuration for qtchooser, but does not prevent alternative Qt
installations from being used.
Homepage: http://qt-project.org/root@Gigabyte-Z68P-DS3:~# dpkg --get-selections | grep dev
comerr-dev install
dpkg-dev install
freeglut3-dev:amd64 install
gir1.2-gudev-1.0 install
krb5-multidev install
libalut-dev install
libasprintf-dev:amd64 install
libboost1.53-dev:amd64 install
libc-dev-bin install
libc6-dev:amd64 install
libdevmapper-event1.02.1:amd64 install
libdevmapper1.02.1:amd64 install
libdrm-dev:amd64 install
libfreetype6-dev install
libgcc-4.8-dev:amd64 install
libgettextpo-dev:amd64 install
libgfortran-4.8-dev:amd64 install
libgl1-mesa-dev install
libgl2ps-dev install
libglu1-mesa-dev install
libgudev-1.0-0:amd64 install
libice-dev:amd64 install
libimobiledevice4 install
libkrb5-dev install
libmtdev1:amd64 install
libmysql++-dev install
libmysqlclient-dev install
libmysqlcppconn-dev install
libopenal-dev:amd64 install
libpcre3-dev:amd64 install
libpthread-stubs0-dev:amd64 install
libqt5opengl5-dev:amd64 install
libroot-core-dev install
libroot-geom-dev install
libroot-graf2d-gpad-dev install
libroot-graf2d-graf-dev install
libroot-graf3d-gl-dev install
libroot-gui-dev install
libroot-hist-dev install
libroot-io-dev install
libroot-math-mathcore-dev install
libroot-math-matrix-dev install
libroot-net-dev install
libroot-proof-dev install
libroot-tree-dev install
libsm-dev:amd64 install
libssl-dev:amd64 install
libstdc++-4.8-dev:amd64 install
libudev1:amd64 install
libudev1:i386 install
libv4l-dev:amd64 install
libx11-dev:amd64 install
libx11-xcb-dev install
libxau-dev:amd64 install
libxcb-dri2-0-dev:amd64 install
libxcb-glx0-dev:amd64 install
libxcb1-dev:amd64 install
libxdamage-dev:amd64 install
libxdmcp-dev:amd64 install
libxext-dev:amd64 install
libxfixes-dev:amd64 install
libxpm-dev:amd64 install
libxt-dev:amd64 install
libxxf86vm-dev:amd64 install
linux-libc-dev:amd64 install
makedev install
manpages-dev install
mesa-common-dev install
python-dbus-dev install
qtbase5-dev:amd64 install
qtbase5-dev-tools install
qtdeclarative5-dev install
system-config-printer-udev install
udev install
unity-scope-devhelp install
x11proto-core-dev install
x11proto-damage-dev install
x11proto-dri2-dev install
x11proto-fixes-dev install
x11proto-gl-dev install
x11proto-input-dev install
x11proto-kb-dev install
x11proto-xext-dev install
x11proto-xf86vidmode-dev install
xserver-xorg-input-evdev install
xserver-xorg-video-fbdev install
xtrans-dev install
zlib1g-dev:amd64 install
root@Gigabyte-Z68P-DS3:~#
-
Did you retry to run qmake now ?
-
[quote author="SGaist" date="1389256104"]Did you retry to run qmake now ?[/quote]
Ok...
Yes... please see again an error:
root@Gigabyte-Z68P-DS3:/opt/Qt5.2.0/5.2.0/Src/qtbase/src/plugins/sqldrivers/mysql# qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
Project ERROR: addExclusiveBuilds() requires at least two arguments
-
Since you installed Qt 5.2 Why didn't you use the qmake from that Qt rather than the one from the system ?
-
Well , I want to build mysql plugin for Qt 5.2 !
I get error message : QMySQL driver not found loaded.I try test with a minimal code :
Main :
@
#include <QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql>
#include <QDebug>//remplacer l'affichage par la commande cout
#define q2c(string) string.toStdString()int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("qtdatabase"); db.setUserName("root"); db.setPassword(""); bool ok = db.open(); return a.exec();
}
@
and .pro :
@
#-------------------------------------------------Project created by QtCreator 2014-01-01T09:22:46
#-------------------------------------------------
QT += core
QT += sql
QT -= guiTARGET = untitled18
CONFIG += console
CONFIG -= app_bundleQTPLUGIN += qsqlmysql
TEMPLATE = appSOURCES += main.cpp
@