我如何在 C++ 中使用 mysql?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1792380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 21:10:30  来源:igfitidea点击:

How I can use mysql in C++?

c++mysql

提问by Lee

I have searched a lot, all I found is a "mysql++" but I don't know how to install it.

我搜索了很多,我发现的只是一个“mysql++”,但我不知道如何安装它。

I don't have knowledge about libraries in C++!

我对 C++ 中的库一无所知!

回答by Lee

Searching google for "c++ mysql tutorial" brings back the following

在谷歌搜索“c++ mysql教程”会带回以下内容

Developing Database Applications Using MySQL Connector/C++

使用 MySQL Connector/C++ 开发数据库应用程序

and A Tiny MySQL++ Tutorial; C++ and MySQL; MySQL++ Example

一个小小的 MySQL++ 教程;C++ 和 MySQL;MySQL++ 示例

Which in turn links to... Installing MySQL++; How to install MySQL++ on Linux-CentOS

依次链接到...安装 MySQL++;如何在 Linux-CentOS 上安装 MySQL++

And looking through the first article I found this Installing MySQL Connector/C++ from Source

浏览第一篇文章,我发现了从源代码安装 MySQL 连接器/C++

They all seem straight forward enough. Although installation processes vary slightly dependant on your operating system.

他们似乎都足够直截了当。尽管安装过程因您的操作系统而略有不同。

回答by Ben S

You need to compile the library for your platform. Visual Studio can be used for Windows. The official web pageof mysql++ has a few FAQs.

您需要为您的平台编译库。Visual Studio 可用于 Windows。mysql++的官网有几个FAQ。

Once you have the library compiled, you can go through the tutorials from the manual.

一旦你编译了库,你就可以阅读手册中的教程。

回答by Adam Casey

Do you already have a running database to access? If so, then mysql++ is straightforward. There's nothing to install; just include the libraries and headers like any other code. There is a simple example here:

您是否已经有要访问的正在运行的数据库?如果是这样,那么 mysql++ 很简单。没有什么可安装的;只需像任何其他代码一样包含库和头文件。这里有一个简单的例子:

http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#simple

http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#simple