Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

QT connection to MYSQL Database tutorial

Shulou Source: shulou.com Published: 2022-06-03 01:41:26 11月19日 Update

Recently purchased Ali Cloud Linux server, for self-study needs to install MYSQL5.7. I'm going to develop a gadget with QT. When I connect to the MYSQL library using the standard classes provided by QT, I keep exposing the problem of not being able to load the MYSQL driver. The software environment is windows10 + Qt4.8.7+mingw+qtcreator. The driver of MYSQL data is not included in this version of Qt4 and needs to be compiled manually. Other tutorials on the Internet are generally aimed at this version of MYSQL5.5, and you need to use the lib file under the / lib/opt path when compiling (accustomed to the Linux system path format, windows format please brain supplement), after many attempts have been unable to solve, had to temporarily abandon this version. The new software environment is Windows10+qt-opensource-windows-x86-5.11.1, and the compilation environment is vc2017. QT5 has inherited the driver of MYSQL database, I thought the problem could be solved, but the previous simple test code:! [] (https://cache.yisu.com/upload/information/20200312/76/258672.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) run to have a look. ! [] (https://cache.yisu.com/upload/information/20200312/76/258673.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) is still the "QSqlDatabase: QMYSQL driver not loaded" that I have seen many times. What should I do? should I give up? Let's check the information. 1. Install mysql5.7 64-bit server programs locally; 2. C:\ Program Files\ MySQL\ MySQL Server 5.7\ lib copy library files 3. Copy lib file to% QTDIR%/lib directory; 4. Copy dll file to% QTDIR%/bin directory 5. Restart Qt Creator while running on the side of the code, the magic time has come, see figure! [] (https://cache.yisu.com/upload/information/20200312/76/258674.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ha, driver loaded successfully!

Tags: Drivers copies files versions environments compilations data code time formats directories paths software problems services tutorials databases success magic tools Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi Shulou Technology Shulou Tech Info Shulou Information