当前位置:网站首页>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
边栏推荐
- Development of user-defined navigation bar in uniapp
- Stringutils and collectionutils
- Why can't it run (unresolved)
- Huawei cloud micro certification Huawei cloud computing service practice has been stable
- Maximum entropy model
- MySQL - use of aggregate functions and group by groups
- Reading notes - learn to write: what is writing?
- SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution
- Pratique technique | analyse et solution des défaillances en ligne (Partie 1)
- Who moved my code!
猜你喜欢

ES6 deletes an attribute in all array objects through map, deconstruction and extension operators

LeetCode226. Flip binary tree

Infiltration learning diary day19

Basic editing specifications and variables of shell script

Remember a lazy query error

Introduction to Tianchi news recommendation: 4 Characteristic Engineering

Will the memory of ParticleSystem be affected by maxparticles

Huawei cloud micro certification Huawei cloud computing service practice has been stable

Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them

String hash, find the string hash value after deleting any character, double hash
随机推荐
Small program graduation project based on wechat e-book small program graduation project opening report function reference
Software product download collection
Who moved my code!
All ceramic crowns - current market situation and future development trend
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
AI helps make new breakthroughs in art design plagiarism retrieval! Professor Liu Fang's team paper was employed by ACM mm, a multimedia top-level conference
MySQL introduction - functions (various function statistics, exercises, details, tables)
What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
TP5 automatic registration hook mechanism hook extension, with a complete case
Conditional statements of shell programming
Force deduction solution summary 1189- maximum number of "balloons"
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
Mongodb learning notes: command line tools
7.1 learning content
Experimental animal models - current market situation and future development trend
It's corrected. There's one missing < /script >, why doesn't the following template come out?
Maximum likelihood method, likelihood function and log likelihood function
Create template profile
Msp32c3 board connection MSSQL method