当前位置:网站首页>The reasons why QT fails to connect to the database and common solutions
The reasons why QT fails to connect to the database and common solutions
2022-07-04 01:45:00 【CAccept】
use qDebug() << db.lastError().text(); Look at the cause of the error
① First, check your database name , user name , Host name , password , Are these port numbers set correctly
For example, if I write the user name wrong, the following error will appear
"Access denied for user 'rot'@'localhost' (using password: YES) QMYSQL: Unable to connect"
The database connection code is as follows
db.setDatabaseName("qtqq");// Database name ( Keep consistent with your settings )
db.setHostName("localhost");// Host name
db.setUserName("root");// user name
db.setPassword("sqhxxxx");// Password and us Mysql Your account and password are the same
db.setPort(3306);// Set the port number
② Look at your Navicat Is it open and connected ( I often forget )
③ If the problem is the lack of drivers, you have to add some files
The problem is displayed as :QMYSQL driver not loaded
resolvent :
mysql Of the installation file lib In the catalog libmysql.dll and libmysqld.dll Copied to the Qt5.5 Medium mingw Of bin Under the document .
If I know the reasons for other types of connection failures later, I will add , Now make do with it
边栏推荐
- C library function int fprintf (file *stream, const char *format,...) Send formatted output to stream
- SQL statement
- All metal crowns - current market situation and future development trend
- Douban scoring applet Part-3
- Small program graduation project based on wechat e-book small program graduation project opening report function reference
- Meta metauniverse female safety problems occur frequently. How to solve the related problems in the metauniverse?
- It's corrected. There's one missing < /script >, why doesn't the following template come out?
- Small program graduation project based on wechat reservation small program graduation project opening report reference
- 51 single chip microcomputer timer 2 is used as serial port
- Applet graduation project based on wechat selection voting applet graduation project opening report function reference
猜你喜欢
Huawei rip and BFD linkage
TP5 automatic registration hook mechanism hook extension, with a complete case
Openbionics robot project introduction | bciduino community finishing
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
Hbuilder link Xiaoyao simulator
Huawei cloud micro certification Huawei cloud computing service practice has been stable
0 basic learning C language - nixie tube dynamic scanning display
Huawei cloud micro certification Huawei cloud computing service practice has been stable
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
Avoid playing with super high conversion rate in material minefields
随机推荐
C import Xls data method summary II (save the uploaded file to the DataTable instance object)
Audio resource settings for U3D resource management
TP5 automatic registration hook mechanism hook extension, with a complete case
Introduction to Tianchi news recommendation: 4 Characteristic Engineering
mysql使用視圖報錯,EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
Avoid playing with super high conversion rate in material minefields
Feign implements dynamic URL
Install the pit that the electron has stepped on
After listening to the system clear message notification, Jerry informed the device side to delete the message [article]
In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
About uintptr_ T and IntPtr_ T type
A fan summed up so many interview questions for you. There is always one you need!
Some other configurations on Huawei's spanning tree
MySQL statement learning record
MySQL -- Introduction and use of single line functions
Huawei cloud micro certification Huawei cloud computing service practice has been stable
Stringutils and collectionutils
Force deduction solution summary 1189- maximum number of "balloons"
It's corrected. There's one missing < /script >, why doesn't the following template come out?
Gnupg website