t-ora issue can't login mysql
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驱动问题 (无需重新编译驱动)
首先遇到的问题,如下:
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文件拷贝到Qt的bin目录中。或者自己编译的时候,链接静态库。
### 老的编译编译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驱动注意要点:
- 先检查".\Qt\4.6.0\plugins\sqldrivers"中有无sql驱动,有的话就别费这劲编译了!
- 安装MySql时要勾住“C Include Files 和 Lib Files”选项,这样才能装上MySql的头文件和链接库。
- 安装MySql时路径中不要有空格,不然编译驱动太费劲(上面的找不到"mysql.h"错误)。
- 命令行进行qmake和nmake前,一定要先转入正确目录(上面的"cannot find file: mysql.pro"错误)!
- 在nmake前最好运行一遍vsvars32.bat批处理(上面的找不到"WinVer.h"错误)。
t-ora issue can't login mysql的更多相关文章
- 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 ...
- (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 ...
- 学习笔记:The Best of MySQL Forum
http://mysql.rjweb.org/bestof.html I have tagged many of the better forum threads. 'Better' is based ...
- 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 ...
- MySQL 优化之 ICP (index condition pushdown:索引条件下推)
ICP技术是在MySQL5.6中引入的一种索引优化技术.它能减少在使用 二级索引 过滤where条件时的回表次数 和 减少MySQL server层和引擎层的交互次数.在索引组织表中,使用二级索引进行 ...
- MySQL入门03-MySQL配置安全性、易用性
一.设定管理员用户和密码 二.处理test库权限隐患 三.自定义脚本提升易用性 中间定义文件 启动MySQL服务 关闭MySQL服务 快捷登录MySQL 四.设置开机自动启动MySQL服务 Refer ...
- 查看mysql版本的四种方法
1:在终端下:mysql -V. 以下是代码片段: [shengting@login ~]$ mysql -V mysql Ver 14.7 Distrib 4.1.10a, for redhat-l ...
- MySQL 5.6.19 二进制安装
1. 操作系统 CentOS release 6.2 (Final) 2. 创建用户和组 [root@mymaster1 ~]# groupadd mysql [root@ ...
- MySQL Linux压缩版安装方法
在诸多开源数据库中,MySQL是目前应用行业,特别是互联网行业发展最好的一个.借助灵活的架构特点和适应不同应用系统场景的Storage Engine,MySQL在很多方面已经有不次于传统商用数据库的表 ...
随机推荐
- Cocos2d-x使用Luajit将Lua脚本编译为bytecode,从而实现加密
转自:http://www.58player.com/blog-2537-87218.html 项目要求对lua脚本进行加密,查了一下相关的资料 ,得知lua本身可以使用luac将脚本编译为字节码(b ...
- Date---String is 合法的date 方法---
package com.etc.jichu; import java.text.SimpleDateFormat; public class IsDate { public static boolea ...
- ng2 中的全屏与退出全屏
1.进入全屏 launchFullscreen(element) { if(element.requestFullscreen) { element.requestFullscreen(); } el ...
- 你可能还会遇到无法启动mysql的错误
解决方法如下:
- 问题:webservice浏览后 无法输入参数;结果:调试Web Service时不能输入参数的解决办法
使用.NET 开发Web Service,有一个很方便的功能就是可以通过IE直接测试Web Service.当你的Web Service的参数都是元数据类型,那么只要你使用IE浏览Web Servic ...
- linux命令-vim编辑模式
按 i 键 进去编辑模式 左下角显示 插入 按 I 键 进入编辑模式 光标到行首 按 a 键 在光标的后一位 按A 键 光标在行尾 按 o 键 在光标下面另起一行 按O 键 在光标上面另起一行 ...
- C语言学习笔记--void关键字
1.C语言中Void关键字的含义 void 修饰函数返回值和参数——为了表示“无”,如果函数没有返回值,那么应该将其声明为 void,同样的,如果函数没有参数,也应该声明其参数为 void //f() ...
- Mac系统的launchd、守护进程daemon(2013笔记整理)
1. launchd Mac系统下通用的进程管理器,是Mac系统下非常重要的一个进程,一般来说该进程不允许直接以命令行的形式调用.只能通过其控制管理界面,launchctl来进行控制. launchd ...
- robot framework结合Jenkins(一)
一.CI与Jenkins介绍: 1.持续集成(CI) 持续集成是一种软件开发实践,即团队开发成员经常集成他们的工作,通过每个成员每天至少集成一次,也就意味着每天可能会发生多次集成.每次集成都通过自动化 ...
- cocos2dx v3.x lua绑定分析
打算新项目转到cocos2dx v3上了,下载代码浏览过后发现改动真是非常大,结构性调整很多. 比如tolua绑定这一块,就几乎全翻新了. 胶水代码的生成,改成了全自动式的,通过clang来分析c++ ...