https://github.com/tora-tool/tora/issues/99

###

TOra is an open-source multi-platform database management GUI that supports accessing most of the common database platforms in use, including Oracle, MySQL, and PostgreSQL, as well as limited support for any target that can be accessed through Qt's ODBC support. TOra has been built for various Linux distributions, Mac OS X, MS Windows, and UNIX platforms.

.ddl 文件是已经编译好的文件,直接放在exe 执行文件同一个目录下,不需要编译,可以识别

.a  文件是没有编译过的。需要编译

###新的版本 Qt 5  (推荐 )

首先遇到的问题,如下:

QSqlDatabase: QMYSQL driver not loaded

QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

Unable to open database

网上大部分帖子都是提出重新编译驱动,其实并不需要这么麻烦。

首先要理解驱动不匹配是怎么回事。我所遇到的问题是我的qt是32位的,但是Mysql却是64位的。使用32位的编译器调用64位的libmysql.dll肯定是不可能调用成功。因此我们只需要到mysql官网下载符合你编译器的dll库就可以。

下载网站:https://dev.mysql.com/downloads/connector/c/

选择符合你的编译器的动态库(32位编译器就下载32位的dll),下载下来。之后将libmysql.dll拷贝到C:\Qt\Qt5.7.0\5.7\mingw53_32\bin目录下即可。

再做连接mysql操作即可发现连接成功。

解决方法:

t-ora 是64bit ,所以下载64bit 的 mysql-connector-c-6.1.11-winx64.zip,然后将其中lib/libmysql.dll 文件copy 到tora 目录下即可,tora 目录下原有的libmysql.dll 需要改名即可。

######参考1

https://blog.csdn.net/u012997311/article/details/51405487

https://blog.csdn.net/Rexlfs/article/details/64906328

Qt不能加载MySql驱动问题 (无需重新编译驱动)
置顶2017年03月22日 11:09:49

阅读数:660

首先遇到的问题,如下:

QSqlDatabase: QMYSQL driver not loaded

QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

Unable to open database

网上大部分帖子都是提出重新编译驱动,其实并不需要这么麻烦。

首先要理解驱动不匹配是怎么回事。我所遇到的问题是我的qt是32位的,但是Mysql却是64位的。使用32位的编译器调用64位的libmysql.dll肯定是不可能调用成功。因此我们只需要到mysql官网下载符合你编译器的dll库就可以。

下载网站:https://dev.mysql.com/downloads/connector/c/

选择符合你的编译器的动态库(32位编译器就下载32位的dll),下载下来。之后将libmysql.dll拷贝到C:\Qt\Qt5.7.0\5.7\mingw53_32\bin目录下即可。

再做连接mysql操作即可发现连接成功。

###参考2

Qt5.7中使用MySQL Driver(需要把libmysql.dll文件拷贝到Qt的bin目录中。或者自己编译的时候,链接静态库)

 

Qt5.7中使用MySQL Driver

1、使用环境

Qt5.7的安装安装就已经带了MySQL Driver,只需要在安装的时候选择一下即可。
如果没有安装,可以采取自己编译的方式。
在Qt的源码包的qtbase\src\sql\drivers\mysql路径下,就是相关的源码文件。
这里就不说编译方式了。只是要记得在编译的时候,需要libmysql的支持。

2、基本使用

    QSqlError err;
// 数据库对象创建
QSqlDatabase db = QSqlDatabase::addDatabase("MYSQL","连接名");
// 设置相关参数
db.setDatabaseName("数据库名"); // 需要与数据库中的一致
db.setHostName("127.0.0.1"); // 主机名(地址)
db.setPort(3366); // 端口 // 打开数据库
if (!db.open("用户名", "密码")) {
err = db.lastError();
db = QSqlDatabase();
QSqlDatabase::removeDatabase("连接名");
}
// Query对象创建
QSqlQuery q("", db);
// 创建一个表
q.exec("create table Names (id integer primary key, Firstname varchar, Lastname varchar, City varchar)");
// 插入三条数据
q.exec("insert into Names values (1, 'Christopher', 'Walker', 'Morristown')");
q.exec("insert into Names values (2, 'Donald', 'Duck', 'Andeby')");
q.exec("insert into Names values (3, 'Buck', 'Rogers', 'Paris')");

3、一个小问题

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

这里需要把libmysql.dll文件拷贝到Qtbin目录中。或者自己编译的时候,链接静态库。

### 老的编译编译Qt 4 的Mysql驱动 make 方法: (源代码版本,不推荐)

There is also a Mingw32 Fedora 11 Cross Compile build
  - see the README file in the win32-cross directory,
  which also contains utility scripts for that build.
   
  Content:
  - Building with MSVC - CMake
  - Building Windows installer.
   
  #
  # Building with MSVC - CMake (+ See README.CMAKE)
  #
  All information below assumes D:\DEVEL as the base directory, and
  D:\DEVEL\tora3 as tora checkout.
   
  1. Download and install "Microsoft Visual Studio 2013 Express" (or higher)
  1a. (Optional) Download and install "Microsoft DirectX SDK (June 2010)"
  1b. (Optional) Download and install "Microsoft Windows SDK v7.1".
  If you have Windows SDK 7.1 use it's command prompt.
  1c. Download and install Git for Windows (https://git-for-windows.github.io/), into D:\DEVEL (or somewhere *without* spaces in the PATH)
   
  ========================== QT 4 Version ========================================
  2. All related steps are done in the "Visual Studio Command Prompt"
  I have MS Visual Studio 2013 Express. (Or Windows SDK 7.1 command prompt).
   
  3. Download and install Active state Perl
   
  4. Download and unzip OpenSSL-<ver>.tgz
  4a. Build OpenSSL as described here: http://qt-project.org/wiki/Building_Qt_Desktop_for_Windows_with_MSVC
  4b. set environment qt32.bat (or qt64.bat)
  4b. perl Configure VC-WIN32 --prefix=D:\Devel\OpenSSL
  4c. ms\do_ms
  4d. nmake -f ms\ntdll.mak
  4e. nmake -f ms\ntdll.mak install
   
  5. Download and unzip Boost headers. The is no need to compile anything. Only few headers are needed.
   
  6. Download and unzip Qt4 source version for Windows. (Version 4.8.5)
  6a. Build OpenSSL as described here: http://qt-project.org/wiki/Building_Qt_Desktop_for_Windows_with_MSVC
  6b. Configure QT: configure.exe -debug-and-release -fast -openssl -webkit -nomake examples -nomake demos -system-proxies -stl
  6c. Compile QT: nmake (and wait)
   
  7. Install Oracle client - instant or standard one. (set env. variable ORACLE_HOME)
   
  8. (Optional) Download and install Postgresql including development packages.
  It's a part of the default install - just check its component.
  NOTE: Install it to the path *without* spaces in its name - Qt has
  problems with compilation in the case of space.
   
  URL: http://www.enterprisedb.com/products/pgdownload.do#windows
  Seems that this installer doesn't prompt for any paths/etc.
  Be sure and disable postgres service after install if you won't be running the server itself
   
  9. (Optional) Download and install MySQL including development packages.
  It's a part of default installer - just check its component.
  NOTE: Install it to the path *without* space in its name - Qt has
  problems with compilation in the case of space.
   
  URL: http://dev.mysql.com/downloads/mysql/5.1.html#win32
  I am testing with the 5.1.37 MSI installer, not the 'Essentials' one
   
  10. Compile QT DB drivers for MySQL and PostgresSQL as described here: http://qt-project.org/doc/qt-4.8/sql-driver.html
  ========================== QT 5 Version ========================================
  2. Download&Install binaries for MSVC
  2a. set env variable QTDIR in MSVC command prompt
  ================================================================================
   
  11. Download and install cmake from www.cmake.org. Into D:\DEVEL (*without* spaces in the PATH)
   
  12. Check and set paths
  - QTDIR
  - CMAKE
  - Doxygen (Optional)
  - OpenSSL
  - Nasm (Optional)
  - Perl
  - DirectX SDK (Optional)
  - Windows SDK 7.1 (Optional)
  - Tortoise SVN (svn.exe is needed while building)
  - MSVC
   
  13. Compile Tora in a GUI.
  cd d:\devel\tora3
  cmake-gui
  - Where is the source core: d:\devel\tora3
  - Where to build the binaries: d:\devel\tora3
  - Add Entry: Name: BOOST_ROOT
  Type: "Path"
  Value" "D:/DEVEL/boost_1_58_0"
  - Add Entry: Name: CMAKE_BUILD_TYPE
  Value: either "Debug", "Release" or "RelWithDebInfo"
  - Toggle WANT_INTERNAL_QSCINTILLA to Y.
  - Toggle WANT_INTERNAL_LOKI to Y.
  - Click Configure/Generate, set generator to Visual Studio 2013 (or Visual Studio 2013 64bit)
  13b. Open Visual Studio 2013 and import solution tora.sln
  13c. Compile projects tora poracle
   
  14. Compile Tora in command prompt
  mkdir d:\devel\tora3\debug
  cd d:\devel\tora3\debug
  cmake -DBOOST_ROOT=D:/DEVEL/boost_1_58_0 -DWANT_INTERNAL_QSCINTILLA=1 -DWANT_INTERNAL_LOKI=1 -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" ..
  nmake
   
  #
  # Testing
  #
  Above build will generate into the tora-build\RELEASE dir. Copy the various dll files from Qt, Postgres, MySQL
  installs into that dir as well:
  MSVC 2013 Runtime libs(optional)
  msvcp120.dll
  msvcr120.dll
  QT4 Libs:
  QtCore4.dll QtGui4.dll QtHelp4.dll QtNetwork4.dll QtSql4.dll QtXml4.dll (put into root)
  qsqlmysqld4.dll qsqlpsql4.dll qsqlodbc4.dll (put into plugins subdir)
  QT5 Libs:
  cd src/RelWithDebInfo
  %QTDIR%/bin/windeployqt tora.exe
   
  Tora Libs:
  poracle.dll
  trotl.dll
  Then you should be able to run tora.exe from that dir. This can be used to test prior to packaging.
   
  #
  # Building Windows installer.
  #
  MSI
  1. Download and install Wix from
  http://wixtoolset.org/
   
  2. Execute the packager
  cd package
  make_msi.bat (resp. make_msi64.bat, make_msi64_qt5.bat)
   
  Please report any bugs should you find them as this port is still in the
 

experimental stage.

#### sample 测试方法 (没通过):

1.Download Visual Studio 2013 for Windows Version: Express Edition

https://en.softonic.com/download/visual-studio-2013/windows/post-download?sl=1

注意是 express 版不是其他版

Visual Studio Express 2012 for Windows Desktop
KEY : MMVJ9-FKY74-W449Y-RB79G-8GJGJ

Microsoft Visual Studio Express 2012 for Web
KEY :VX3VY-8GCVT-KJQCY-RQ99X-MCF2R

2.qt-opensource-windows-x86-msvc2015-5.7.1.exe

http://download.qt.io/official_releases/qt/5.7/5.7.1/

https://blog.csdn.net/qq_39340204/article/details/78594854?locationNum=4&fps=1

D:\Qt\Qt5.7.1

2.2 mysql
C:\wamp64\bin\mysql\mysql5.7.9\

https://blog.csdn.net/qq_39340204/article/details/78593512

2.3 t-ora
C:\Users\penghuishun.CRBCOA\AppData\Local\Apps\Tora

2.4 cmake
https://cmake.org/download/

C:\Users\penghuishun.CRBCOA\AppData\Local\Apps

3.
All information below assumes C:\Users\penghuishun.CRBCOA\AppData\Local\Apps as the base directory, and
C:\Users\penghuishun.CRBCOA\AppData\Local\Apps\Tora as tora checkout.

2. All related steps are done in the "Visual Studio Command Prompt"

Download&Install binaries for MSVC
2a. set env variable QTDIR in MSVC command prompt
.

@ECHO OFF

set DEV1=D:\Qt\Qt5.7.1set QTDIR=%DE1V%set PATH=%SystemRoot%;%SystemRoot%32;%QTDIR%;

set PATH=%SystemRoot%;%SystemRoot%32;C:\Users\penghuishun.CRBCOA\AppData\Local\Apps\CMake\bin

echo Setting MSVC2010 Env.
set DEV=C:\Users\penghuishun.CRBCOA\AppData\Local\Apps\Common
set VSINSTALLDIR=%DEV%set VCINSTALLDIR=%DEV%set DevEnvDir=%VSINSTALLDIR%7\IDE
set PATH=%VCINSTALLDIR%;%VSINSTALLDIR%7\Tools;%VSINSTALLDIR%7\IDE;%VCINSTALLDIR%;%PATH%
set INCLUDE=%VCINSTALLDIR%;%INCLUDE%
set LIB=%VCINSTALLDIR%;%LIB%
set LIBPATH=%VCINSTALLDIR%

echo Env. ready.

================================================================================

11. Download and install cmake from www.cmake.org. Into D:\DEVEL (*without* spaces in the PATH

12. Check and set paths
- QTDIR
- CMAKE
- Doxygen (Optional)
- OpenSSL
- Nasm (Optional)
- Perl
- DirectX SDK (Optional)
- Windows SDK 7.1 (Optional)
- Tortoise SVN (svn.exe is needed while building)
- MSVC

14. Compile Tora in command prompt
mkdir d:\devel\tora3\debug
cd d:\devel\tora3\debug
cmake -DBOOST_ROOT=D:/DEVEL/boost_1_58_0 -DWANT_INTERNAL_QSCINTILLA=1 -DWANT_INTERNAL_LOKI=1 -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" ..

(测试失败,因为下载的不是安装qt,需要安装源代码版本,我们下载的是exe 版本,所以这次测试失败的,找不到mysql.pro)
nmake

######
How to Build the QMYSQL Plugin on Windows
You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. Build the plugin as follows (here it is assumed that MySQL is installed in C:\MySQL):

cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\MySQL Server <version>\lib\opt\libmysql.lib" mysql.pro
nmake
######

https://blog.csdn.net/qq_39340204/article/details/78594854?locationNum=4&fps=1

https://www.cnblogs.com/codingmylife/archive/2010/01/19/1678530.html

https://jingyan.baidu.com/article/27fa7326ffb99146f8271fe0.html

https://blog.csdn.net/gzshun/article/details/8493864

###

编译QT的MySql驱动问题及解决方案

 

做毕业设计要用到MySql,界面方面想用下QT,顺便学习一下QT的使用。上去就碰到问题,没有MySql的驱动(其实在.\Qt\4.6.0\plugins\sqldrivers目录下有,后来编译完了才发现,这里要崩溃一下~)。GOOGLE了一下,翻了翻网页,就开始编译驱动了。

这里使用QT4.6.0版本和VS2008自带的编译器

使用的命令行参数是:

qmake –o Makefile INCLUDEPATH+="D:\Program Files\MySQL\MySQL Server 5.1\include" LIBS+="D:\Program Files\MySQL\MySQL Server 5.1\lib\opt\libmysql.lib" mysql.pro
nmake

跟预料中的一样,编译出错,错误是"cannot find file: mysql.pro",费了半天劲终于发现我进入的目录是".\Qt\4.6.0\src\sql\drivers\mysql"而不是传说中的".\Qt\4.6.0\src\plugins\sqldrivers\mysql"(本目录才是正确路径!)。发生本错误的同志们一定要检查一下命令行的路径进的是否正确!

一个问题解决了,qmake成功完成,开始nmake。这里先是碰到了qsqlmysqld_resource.rc中找不到"WinVer.h"的错误。找了找,发现WinVer.h头文件居然在Windows SDK的文件夹下,于是在".\Microsoft Visual Studio 9.0\Common7\Tools"中找到了vsvars32.bat设置环境变量的批处理,把该批处理拖入命令行窗口运行一遍(注意该批处理仅设置本次命令行窗口中的环境变量,并未修改注册表,所以每次打开个新命令行窗口都要运行一次批处理才可获得其中包含的环境变量设置!),再nmake,找不到WinVer.h的问题解决了。

再次nmake,这次问题就诡异了,居然找不到"mysql.h"!但mysql.h已经在qmake的INCLUDEPATH参数中包含进去了,怎么可能找不到?郁闷,打开Makefile.Debug看看,发现里面INCLUDE进去的"D:\Program Files\MySQL\MySQL Server 5.1\include"每个空格处都被认为是一个路径,好好的路径给分的希碎,qmake的智商太低了!没法,把MySQL Server 5.1文件夹下的include和lib文件夹直接拷贝到根目录下,这样INCLUDEPATH和LIBS路径均无空格,再次qmake、nmake,OK了!

总结:QT编译MySql驱动注意要点:

  1. 先检查".\Qt\4.6.0\plugins\sqldrivers"中有无sql驱动,有的话就别费这劲编译了!
  2. 安装MySql时要勾住“C Include Files 和 Lib Files”选项,这样才能装上MySql的头文件和链接库。
  3. 安装MySql时路径中不要有空格,不然编译驱动太费劲(上面的找不到"mysql.h"错误)。
  4. 命令行进行qmake和nmake前,一定要先转入正确目录(上面的"cannot find file: mysql.pro"错误)!
  5. 在nmake前最好运行一遍vsvars32.bat批处理(上面的找不到"WinVer.h"错误)。

t-ora issue can't login mysql的更多相关文章

  1. Failed to issue method call: Unit mysql.service failed to load: No such file or directory解决的方式

    Failed to issue method call: Unit mysql.service failed to load: No such file or directory解决的方式 作者:ch ...

  2. (phpmyadmin error)Login without a password is forbidden by configuration (see AllowNoPassword) in ubuntu

    1.Go to /etc/phpmyadmin/config.inc.php and open it your favorite editor. 2.Search for below line of ...

  3. 学习笔记:The Best of MySQL Forum

    http://mysql.rjweb.org/bestof.html I have tagged many of the better forum threads. 'Better' is based ...

  4. mysql的TABLE_SCHEMA的sql和information_schema表, MySQL管理一些基础SQL语句, Changes in MySQL 5.7.2

    3.查看库表的最后mysql修改时间, 如果第一次新建的表可能还没有update_time,所以这里用了ifnull,当update_time为null时用create_time替代 select T ...

  5. MySQL 优化之 ICP (index condition pushdown:索引条件下推)

    ICP技术是在MySQL5.6中引入的一种索引优化技术.它能减少在使用 二级索引 过滤where条件时的回表次数 和 减少MySQL server层和引擎层的交互次数.在索引组织表中,使用二级索引进行 ...

  6. MySQL入门03-MySQL配置安全性、易用性

    一.设定管理员用户和密码 二.处理test库权限隐患 三.自定义脚本提升易用性 中间定义文件 启动MySQL服务 关闭MySQL服务 快捷登录MySQL 四.设置开机自动启动MySQL服务 Refer ...

  7. 查看mysql版本的四种方法

    1:在终端下:mysql -V. 以下是代码片段: [shengting@login ~]$ mysql -V mysql Ver 14.7 Distrib 4.1.10a, for redhat-l ...

  8. MySQL 5.6.19 二进制安装

    1.        操作系统 CentOS release 6.2 (Final) 2.        创建用户和组 [root@mymaster1 ~]# groupadd mysql [root@ ...

  9. MySQL Linux压缩版安装方法

    在诸多开源数据库中,MySQL是目前应用行业,特别是互联网行业发展最好的一个.借助灵活的架构特点和适应不同应用系统场景的Storage Engine,MySQL在很多方面已经有不次于传统商用数据库的表 ...

随机推荐

  1. DotNetBar 第三方控件使用

    1.BalloonTip(气泡提醒) 效果: 代码: balloonTip1.SetBalloonCaption(txtusername, "提示");            ba ...

  2. Android Studio配置使用git

    一.准备 如果没有安装git,那么先要到到Git官网下载git,然后按照提示一步一步安装即可,这个没有什么难度,不过要记得安装的目录. 二.Android Studio配置git File->S ...

  3. 高级查询子条件查询filter

    Filter Context 在查询过程中,只判断该文档是否满足条件,只有Yes或者No { "query":{ "bool":{ //布尔关键词 " ...

  4. SpringSecurity01 SpringSecurity环境搭建

    版本说明: JDK -> java version "1.8.0_101" MAVEN -> Apache Maven 3.5.0 IDEA -> 2017.2. ...

  5. error C2144: 语法错误:“int”的前面应有“;”

    error C2144: 语法错误:"int"的前面应有";" C++- error C2144 syntax error : 'int' should be ...

  6. Struts2 资源配置文件国际化

    Struts2 资源配置文件国际化 Struts2资源文件的命名规范:basename_language_country.properties Struts2国际化如果系统同时存在资源文件.类文件,系 ...

  7. jquery提供的数据提交方式2-ajax

    以前介绍过ajax提交方式.但仅仅是个例子,今天将详细介绍jquery中的$.ajax,$.get,$.post方法. 一,首先介绍$.ajax方法参数(以下参数来自:http://www.cnblo ...

  8. 7.24实习培训日志-Docker-Compose

    Docker-Compose 对于昨天的考试,需要 项目根目录下需要docker/mysql/Dockerfile 文件用于构建mysql镜像 项目根目录下需要docker/java/Dockerfi ...

  9. HDU 5974 A Simple Math Problem (解方程)

    题意:给定a和b,求一组满足x+y=a && lcm(x, y)=b. 析:x+y = a, lcm(x, y) = b,=>x + y = a, x * y = b * k,其 ...

  10. App知识点汇总

    1.Fragment 2.AndroidStudio 用夜神安卓模拟器调试 进入夜神模拟器安装目录下的bin目录,执行nox_adb.exe connect 127.0.0.1:62001,Andro ...