Server/C++

C++ MySQL 연동 - ODBC

Juzdalua 2024. 11. 21. 15:51

 

1. ODBC 드라이버 다운로드 및 설치

https://dev.mysql.com/downloads/connector/odbc/

 

MySQL :: Download Connector/ODBC

Connector/ODBC is a standardized database driver for Windows, Linux, Mac OS X, and Unix platforms Online Documentation: The latest MySQL Connector/ODBC version is recommended for use with MySQL Server version 8.0 and higher. Please report any bugs or incon

dev.mysql.com

 

2. MySQL ODBC 등록

Window 키 - ODBC 데이터 원본 관리자 - 사용자DSN, 시스템DSN 추가 - 설치한 MySQL Unicode 드라이버

 

test success

 

3. 프로젝트 ODBC 라이브러리 링크

 

4. MySQL Connection String

 

C++ 코드에 들어가는 드라이버명은 파란색으로 선택된, 설치한 드라이버 이름을 작성한다.

const WCHAR* cs = L"Driver={MySQL ODBC 9.1 Unicode Driver};Server=127.0.0.1;Database=DATABASE_NAME;UID=USER_NAME;PWD=USER_PASSWORD";

 

 

코드)

https://github.com/Juzdalua/Chat-Server/blob/main/Server/DBConnection.h

 

Chat-Server/Server/DBConnection.h at main · Juzdalua/Chat-Server

C++ TCP IOCP Chat. Contribute to Juzdalua/Chat-Server development by creating an account on GitHub.

github.com

 

ODBC C 데이터 형식)

https://learn.microsoft.com/ko-kr/sql/odbc/reference/appendixes/c-data-types?view=sql-server-ver16

 

C 데이터 형식 - ODBC API Reference

C 데이터 형식

learn.microsoft.com

 

'Server > C++' 카테고리의 다른 글

비트연산  (0) 2025.04.17
C++ 환경변수 .env 파일 사용하기  (0) 2025.01.03
JSON 사용하기 - nlohmann json  (1) 2024.11.20
Boost 라이브러리 사용하기  (0) 2024.11.19
C++ MySQL 연동 - Connector/C++  (0) 2024.08.30