- Download and install MySQL installer
- Using MySQL installer install
MySQL Community Server 8.0.X
andMySQL Connector /C++ 1.1.13
- Create database using this template
CREATE DATABASE tutorial;
USE tutorial;
CREATE TABLE test (id int, name varchar(32), score int);
INSERT INTO test (id, name, score) VALUES (1, "Szymon", 99);
INSERT INTO test (id, name, score) VALUES (2, "Tomek", 50);
INSERT INTO test (id, name, score) VALUES (3, "Mateusz", 78);
SELECT * FROM test;
- Create new console app project
- Change Solution Configuration to
Release
and Solution platform tox64
- Right click to your project section and select properties
- Go to
C/C++
section and selectGeneral
- Select Additional Include Directories and add this directories
C:\Program Files\MySQL\Connector C++ 1.1\include
,C:\Program Files\MySQL\MySQL Server 8.0\include
- Go to
Linker
section and selectGeneral
- Select Additional Library Directories and add this directories
C:\Program Files\MySQL\Connector C++ 1.1\lib\opt
,C:\Program Files\MySQL\MySQL Server 8.0\lib
- Move to
Input
inLinker
section - Select Additional Dependencies and add this libraries
mysqlcppconn.lib
,libmysql.lib
- Code your app and build
- After building go to directory with your executable file and paste there this DLLs
libmysql.dll
fromC:\Program Files\MySQL\MySQL Server 8.0\lib
libcrypto-1_1-x64.dll
andlibssl-1_1-x64.dll
fromC:\Program Files\MySQL\MySQL Server 8.0\bin
- Run your app and enjoy :-)
I am not the author of this solution, I have corrected as well as shared in text version a 2018 tutorial found on Youtube