第一步:请阅读http://user.qzone.qq.com/378100977/blog/1430883016这位仁兄的链接,经过我的实际测试。这篇文章的代码没有问题。
第二步:这篇文章中未解决的问题:
程序可以编译,但是链接找不到libmysql。解决的办法就是将libmysql.dll放到Binaries中。
文章中使用了绝对路径,比较LOW,估计作者也是稀里糊涂,没有深究。我们要相对路径!!! 做法:将文章中的PrivateIncludePaths改成PublicIncludePaths.为什么这么改就可以了。可以看一下这两个函数的注释!有些朋友使用比较新的UE版本,可能会遇到RulesCompiler.GetModuleFileName(String)已过时的问题,解决办法如下:
RulesAssembly RA;
FileReference CheckProjectFile;
UProjectInfo.TryGetProjectForTarget("工程名", out CheckProjectFile);
RA = RulesCompiler.CreateProjectRulesAssembly(CheckProjectFile);
FileReference FR = RA.GetModuleFileName(this.GetType().Name);
string ModulePath = Path.GetDirectoryName(FR.CanonicalName);

第三步:到这一步,很多新手花了很多时间,欣喜若狂。被UE折腾的扎耳挠思。终于编译,调用没有问题了。谢天谢天。那么问题来了,这时候发现 读取MYSQL中的中文数据后显示的都是乱码!!(如果你MySQL还没连上,请不用往下看了。。)
乱码问题:
中文乱码无非就是编码格式问题。MySQL现在默认都是UTF8编码。不存在语言障碍。那为什么还是乱码呢?当然,还是编码问题!
解决乱码问题:
在mysql_real_connect后,程序中设置编码为mysql_set_character_set(mysql, "utf8");【可能有人问,MySQL不是默认UTF8吗?为什么还要设置?sorry,就得设置,否则无法正确显示。修改MySQL配置文件也不行】。
将读出的数据使用UTF8_TO_TCHAR()函数转码。到此,中文乱码问题解决。有了TCHAR,就拥有了FString.什么都不怕了!
第四步:如何访问MySQL数据库,使用语句还是存储过程?我的建议是,都搞搞。那个爽,用那个。存储过程是MSSQL的TSQL集合,访问数据库效 率高,速度快!以前MySQL都没有,终于良心发现,加上了。在目前的高版本中基本都支持。那么问题来了,怎么调用呢?请百度,大把的文章!
using System.IO;namespace UnrealBuildTool.Rules
{public class MySQLSupport : ModuleRules{public MySQLSupport(ReadOnlyTargetRules Target) : base(Target){PrivateDependencyModuleNames.AddRange(new string[] {"Core","CoreUObject","Engine",});RulesAssembly RA;FileReference CheckProjectFile;UProjectInfo.TryGetProjectForTarget("VRHome", out CheckProjectFile);RA = RulesCompiler.CreateProjectRulesAssembly(CheckProjectFile);FileReference FR = RA.GetModuleFileName(this.GetType().Name);string ModulePath = Path.GetDirectoryName(FR.CanonicalName);//string ModulePath = Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name));         // gets the directory path of this module        string ThirdPartyPath = Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/"));                 // gets the ThirdParty folder directory path        string MySQLConnectorPath = ThirdPartyPath + "MySQL Connector.C6.1/";                                    // gets the MySQL Connector.C 6.1 folder path        string MySQLConnectorLibraryPath = MySQLConnectorPath + "lib/";                                          // gets the path of the lib folder        string MySQLConnectorIncludePath = MySQLConnectorPath + "include/";                                      // gets the path of the include folder        string MySQLConnectorImportLibraryName = Path.Combine(MySQLConnectorLibraryPath, "libmysql.lib");        // gets the file path and name of the libmysql.lib static import library        string MySQLConnectorDLLName = Path.Combine(MySQLConnectorLibraryPath, "libmysql.dll");                  // gets the file path and name of libmysql.dll        if (!File.Exists(MySQLConnectorImportLibraryName))                                                       // check to ensure the static import lib can be located, or else we'll be in trouble        {throw new BuildException(string.Format("{0} could not be found.", MySQLConnectorImportLibraryName));        // log an error message explaining what went wrong if not found        }if (!File.Exists(MySQLConnectorDLLName))                                                                 // check to make sure the dll can be located or else we'll be in trouble        {throw new BuildException(string.Format("{0} could not be found.", MySQLConnectorDLLName));           // log an error message explaining what went wrong if not found        }PublicIncludePaths.Add(MySQLConnectorIncludePath);                                                       // add the "include" folder to our dependencies. I've chosen PrivateIncludePaths since I hide the mysql headers from external code        PublicLibraryPaths.Add(MySQLConnectorLibraryPath);                                                       // add the "lib" folder to our dependencies        PublicAdditionalLibraries.Add(MySQLConnectorImportLibraryName);                                          // add libmysql.lib static import library as a dependency        PublicDelayLoadDLLs.Add(MySQLConnectorDLLName);                                                          // add libmysql.dll as a dll    RuntimeDependencies.Add(new RuntimeDependency("$(ProjectDir)/Binaries/Win64/libmysql.dll"));             // 自动添加libmysql.dll到指定的打包目录中}}
}

UE4连接Mysql数据库解决方案相关推荐

  1. 在java中使用JDBC连接mysql数据库时的服务器时区值无法识别或表示多个时区的问题解决方案

    项目场景: 在java中使用JDBC连接mysql数据库时,报以下的错:Exception in thread "main" java.sql.SQLException: The ...

  2. node 连不上 mysql_node连接mysql数据库遇到的问题和解决方案

    今天安装了新版的MySQL(8.0.21),用node框架连接数据库的时候报了个错: Client does not support authentication protocol requested ...

  3. QSqlDatabase连接MySQL数据库提示driver not loaded的解决方案

    QSqlDatabase连接MySQL数据库提示driver not loaded的解决方案 环境 VS2019 mysql Ver 14.14 Distrib 5.7.36, for Win64 ( ...

  4. mysql安装连接测试c_C连接MySQL数据库开发之Windows环境搭建及测试_MySQL

    一.开发环境 Win8.1 64位.VS2013.MySQL5.5.3764位 MySQL安装目录为:C:/Program Files/MySQL/MySQL Server 5.5二.配置工程环境 首 ...

  5. vs中如何开发mysql_VS2015如何连接mySQL数据库图文

    1.新建一个工程名叫mysql,编程环境选择c#,然后选择windows窗体应用程序,新建一个窗体用于显示查询到sql数据库的数据集 2.从工具箱向form1窗体上拖一个按钮和datagridview ...

  6. C连接MySQL数据库开发之Windows环境配置及测试

    一.开发环境 Win8.1 64位.VS2013.MySQL5.5.3764位 MySQL安装目录为:C:\Program Files\MySQL\MySQL Server 5.5 二.配置工程环境 ...

  7. c mysql 内存泄露_c代码连接mysql数据库内存泄露的问题

    一直使用C代码连接mysql数据库,今天用valgrind检测,发现存在内存泄露的问题 代码如下 MYSQL*connection; connection=mysql_init(); connecti ...

  8. Python——Python连接MySQL数据库

    基本概念 PyMySQL:PyMySQL是封装了MySQL驱动的Python驱动,一个能使Python连接到MySQL的库. mysql-connector-python(MySQL Connecto ...

  9. C++踩坑之连接mysql数据库

    C++踩坑之连接mysql数据库 实现的效果 https://www.cr173.com/soft/105990.html 下载connect C++ 安装软件 安装到D盘,安装32位即可 64位不要 ...

最新文章

  1. 二叉搜索树的第 k 大节点(递归,反中序遍历 + 提前返回)
  2. 迈向智慧化 物联网规模应用不断拓展
  3. oracle 创建 触发,Oracle 创建触发器
  4. 人脸识别技术大总结(1)——Face Detection Alignment
  5. 【bzoj1486】【[HNOI2009]梦幻布丁】启发式链表合并(详解)
  6. 微信支付分申请接入流程
  7. mac下beyond compare配置图
  8. 全栈深度学习第7期: 研究方向这么多,哪些是有有趣又潜力的呢?
  9. 永洪bi_案例分享!永洪BI助力知名三甲医院数字化转型升级
  10. python选课系统代码_python模拟选课系统
  11. 10本书,搞定这门全球1000万程序员在用的编程语言
  12. 初识生成器与生成器表达式 Day12
  13. php提示修改成功,提示修改成功后怎么换回原来的页面
  14. 啥他妈的是 Nginx?
  15. 永洪BI在 Linux/Unix 下 jdk 环境如何配置?
  16. 全开源!Office多人协作应用,在线编辑Word、Excel和PPT文档
  17. NPN型三极管基础知识解析
  18. linux子系统下载错误,Win10系统开启linux子系统报错“0x80070057”怎么办?
  19. 供应链金融科技产品的核心竞争力究竟是什么?
  20. Mac看电视直播(通过MUMU安卓模拟器+自定义直播软件apk)

热门文章

  1. 物联网+智能垃圾分类回收系统解决方案
  2. 曾国藩经典人生哲理语录——大师级别啊
  3. Rootkit与后门隐藏
  4. 用python画小黄人-学Python画画:应用Turtle库画一个蠢萌的小黄人
  5. 使用js统计两个日期之间去掉(周六,周日)
  6. Mysql InnoDB存储引擎【二】InnoDB Buffer Pool 缓存池
  7. iOS流布局之UICollectionView简单应用
  8. 推荐一款非常好用的博客系统 halo
  9. 苹果id可以彻底注销吗_公司注销之后商标可以转让给个人吗?
  10. python字节和字符串互转