Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

QT 5 configure MySQL process logging

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Record the configuration process. When you get old, you have a poor memory.

0 installation environment

Win10x64+Qt5.5 (x86) + VS2010 (x86)

1 install MySQL

Note:

The following is installed according to x64 version, and there is no difference in the installation process of x86 version.

The version of MySQL installation should correspond to the version of Qt. Keep in mind! Remember!

1.1 download

Http://dev.mysql.com/downloads/mysql/

Select mysql-5.7.14-winx64.zip to download

1.2 decompression

Extract the files to the installation directory

Note: do not leave spaces in the installation directory

1.3 configuration

(1) rename my-default.ini to my.ini

The content is modified as follows:

[client]

Port=3306

Default-character-set=utf8

[mysql]

# set mysql client default character set

Default-character-set=utf8 [mysqld]

# set port 3306

Port = 3306

# set the installation directory of mysql

Basedir=C:/MySQL/mysql-5.7.14-winx64

# set the storage directory of the data in the mysql database

Datadir=C:/MySQL/mysql-5.7.14-winx64/data

# maximum number of connections allowed

Max_connections=200

# the character set used by the server defaults to the 8-bit coded latin1 character set

Character-set-server=utf8

# default storage engine to be used when creating new tables

Default-storage-engine=INNODB

Sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[WinMySQLAdmin]

C:/MySQL/mysql-5.7.14-winx64/bin/mysqld.exe

(2) run the command prompt cmd as an administrator

(3) change the directory cd / dC:/MySQL/mysql-5.7.14-winx64/bin

(4) perform the installation of mysqld-install

(5) initialize mysqld-initialize-console

Successful initialization will set a temporary password for the root account. Be sure to remember this password.

After successful initialization, the data directory is created in datadir

Note: do not create the data directory in advance, it may cause installation failure

(7) start the service net start mysql

A prompt will be given if the service starts successfully.

If it doesn't work, uninstall it with mysqld-- remove and try again.

If you are reinstalling MySQL, stop the running service net stop mysql first

Then uninstall mysqld-- remove

(8) Log in for the first time and change the password mysqladmin-u root-p password

(9) log in to mysql-u root-p

Show the built-in database

(10) set up the database for testing

Create database bz

Use bz

Create table user (userid INT NOT NULL AUTO_INCREMENT

-> username VARCHAR (256) NOT NULL

-> userpassword VARCHAR (256) NOT NULL

-> useremail VARCHAR (256) DEFAULT NULL

-> usermobile VARCHAR (32) DEFAULT NULL

-> PRIMARY KEY (userid))

Insert into user (username, userpassword) values ("Apple", "p1")

Insert into user (username, userpassword) values ("Bob", "p2")

Insert into user (username, userpassword) values ("Cat", "p3")

Insert into user (username, userpassword) values ("Dog", "p4")

Inquire about

The database is ready, then configure Qt

2 configure Qt5.5

Version 2.0 Qt

You can download various versions of Qt http://download.qt.io/archive/qt/ here

Note: the version of Qt5.5+VS is only x86, not x64

This hurts so much. The previous MySQL was all installed and configured according to the x64 version at first, but it took a long time to see a message on Zhihu saying that it might be the problem of x86 and x64.

2.1 Test code

# include

# include

# include

# include

# include

Bool createConnection ()

Void queryDatabase ()

Void availableDrivers ()

Int main (int argc, char * argv [])

{

QCoreApplication a (argc, argv)

AvailableDrivers ()

If (! createConnection ()

Return 1

QueryDatabase ()

Return a.exec ()

}

Void availableDrivers ()

{

QDebug ()

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report