Setting up MySQL for Qt on Ubuntu



  • Hello!
    I am new to Qt, and I've been trying to set up qt to be able to use mysql.
    I'm not really sure what I should do...
    Do I have to install some drivers or what?
    I am asking now, what should I do to get it working on Ubuntu.

    Thanks already in advance



  • @sudo apt-get install libmysqlclient-dev
    cd $QTDIR/src/plugins/sqldrivers/mysql
    qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
    make
    make install@



  • [quote author="ucomesdag" date="1296058771"]@sudo apt-get install libmysqlclient-dev
    cd $QTDIR/src/plugins/sqldrivers/mysql
    qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
    make
    make install@[/quote]

    Thanks for the reply, but I didn't succeed to finish it.
    When I tried the make, it gave me this error:

    @~/qtsdk-2010.05/qt/src/plugins/sqldrivers/mysql$ make
    g++ -c -pipe -O2 -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I/usr/include/mysql -I. -o main.o main.cpp
    main.cpp:42: fatal error: qsqldriverplugin.h: File or folder does not exist
    compilation terminated.
    make: *** [main.o] Error 1
    @

    What could go wrong?



  • You're using the wrong qmake.



  • Try and apt-get libqt4-sql and libqt4-sql-mysql or something similar the easy way to get qt on ubuntu is to apt get qt-creator and qt and if you need extra drivers for sql just use the previous commands i wrote apt-get libqt4-sql and libqt4-sql-mysql for mysql libqt4-sql-psql for postgre etc you get the point.



  • the sdk. It doesn't exist.[/quote]

    My friend try go in Qt Tools>Options>QtVersions>In Autodetected chose you Qt compiler>Look down click on Qt version 5 Details. Now look you PLUGINS folder and go. In sqldrivers folder check file libqsqlmysql.so exist and ins not protected.
    If u not have this file download form Ubuntu software center searching libqt5 for QT5 or liqt4 for QT4 and install later copy the installed file /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers for 64bits machine or /usr/lib/i386-linux-gnu/qt5/plugins/sqldrivers for 32bits machine. to you plugins proyect folder
    Sorry for my english regars from Argentina



  • Tried many other suggestions and all failed. This one is straightforward and worked. In Ubuntu repository, search for 'Qt 5 MySQL', install and done!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.