QT5.4 medium MySQL5.6 Drive configuration
1. go to the download directory and execute the following statement below the Ubuntu terminal without root privileges:
./Qt-opensource-linux-x86-5.4.0.run
2. The Qt installation dialog will appear next , click "Next" to perform the next step:
3. Next Select the installation location. Because it is not rooted , it is recommended to install it in the user directory:
4. Select the components that need to be installed, which you can select as needed:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/07/wKiom1fRoxTyTBKMAACfnyKEmV8284.png-wh_500x0-wm_3 -wmp_4-s_1050559469.png "title=" 111.png "alt=" Wkiom1froxtytbkmaacfnykemv8284.png-wh_50 "/>
Here's Source must be checked, only
[Email protected]_:/home/ukylin/qt5.4.0/5.4/src/qtbase/src/plugins/sqldrivers/mysql directory
https://pkgs.org/
Download and follow the installation sequence:
first one:mysql-common_5.6.31-0ubuntu0.15.10.1_all.deb
The second one:libmysqlclient18_5.6.25-0ubuntu1_i386.deb
The third one:libmysqlclient-dev_5.6.25-0ubuntu1_i386.deb
order is:dpkg-i file.deb
Switch directory:/home/ukylin/qt5.4.0/5.4/src/qtbase/src/plugins/sqldrivers/mysql
First step:qmake "Includepath+=/usr/local/include" "Libs+=-l/usr/local/lib-lmysqlclient_r" Mysql.pro This is generally a general-purpose configuration.
My Computer is qmake "Includepath+=/opt/mysql/server-5.5/include" "libs+=-l/opt/mysql/server-5.5/lib-lmysqlclient _r "Mysql.pro
Tip: Re -make required:make clean
Step two:make
Step Three:make install
Fourth Step: View cd/home/ukylin/qt5.4.0/5.4/gcc/plugins/sqldrivers/
input:ldd libqsqlmysql.so view dependencies.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/07/wKiom1fRoyuiW0FwAAEJlMCrDaM488.png "title=" 2222. PNG "alt=" Wkiom1froyuiw0fwaaejlmcrdam488.png "/>
Open a project and try it:
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/87/05/wKioL1fRoz-CLS-XAACGKrmru6s498.png "title=" 333. PNG "alt=" Wkiol1froz-cls-xaacgkrmru6s498.png "/>
I give a solution here, but you have to have a certain understanding of the database, or later you will be difficult to deal with:
One:cd/var/run/
II:mkdir mysqld
Third: Close the MySQL server to see if it is closed:ps-ef | grep msyql;
Four: Install directory: Modify my.cnf
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/87/05/wKioL1fRo1Oy7YF_AABCR7upn3E401.png "title=" 444. PNG "alt=" Wkiol1fro1oy7yf_aabcr7upn3e401.png "/>
Five: Start mysql server:service MySQL Start
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/87/07/wKiom1fRo2yQkDkqAAAmAsyDu8M279.png-wh_500x0-wm_3 -wmp_4-s_2549147670.png "title=" 555.png "alt=" Wkiom1fro2yqkdkqaaamasydu8m279.png-wh_50 "/>
The connection was successful. Last execution:ln-s/var/run/mysqld/mysqld.sock/tmp/mysql.sock hard links.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/07/wKiom1fRo6nxIFN2AACNDIvy1O8931.png "title=" 666. PNG "alt=" Wkiom1fro6nxifn2aacndivy1o8931.png "/>
powerful Linux. The above is the color when the server is running. The following is the server off color, the file disappears.
The final test:
Void mainwindow::showdatabasedataslot () { this->db = qsqldatabase:: Adddatabase ("Qmysql");//Load Driver this->db.sethostname ("localhost"); this->db.setusername ("root"); this->db.setpassword ("root"); this->db.setdatabasename ("student"); bool ok = db.open (); if (OK) { qdebug () << " open database success "; }else{ qdebug () << "Error open database because" << this- >db.lasterror (). Text (); } qsqlquery query; query.exec ("Select * from information"); //return the databases recorder&nbSp; while (Query.next ()) { int id= Query.value (0). ToInt (); qstring name=query.value (1). ToString (); qstring address=query.value (2). ToString (); qstring contact=query.value (3). toString (); qdebug () <<id<<name<<address<<contact; } this->db.close ();}
Project files don't forget to add QT + = SQL
This article from "Xiao Wu" blog, reproduced please contact the author!
Ubuntu15.04 QT5.4 Compilation configuration MySQL5.6.26 Connection driver