MySQL Installation and Setup for C++ Development on Visual Studio

preview_player
Показать описание
UPDATE 5 August 2020:
I am happy for those of you who managed get your setup working. I am sorry to those who could not despite following my steps. I am nowhere near proficient in this domain, and happened to need this setup at that time. Since then, I do not require it anymore. I spent hours figuring out what worked for my setup and these are the steps for me. It may or may not work for you, and I admit I wouldn't know how to make it work if your setup is different from mine. Apologies in advance to whom I am not able to provide any good advice. Wishing you the best.

------------------------------------------------------------------------------------------------------------------------------------------------------------

Step-by-step tutorial in installing MySQL Server and Connector/C++ 8.0.11 for C++ application development on Visual Studio Community 2017. This tutorial also shows the end result of running a simple C++ Windows Console Application that connects to the MySQL Server and displays table data.

System specs for this tutorial
⦁ Windows 10 Professional
⦁ 64 Bit machine
⦁ Visual Studio Community 2017 (with Microsoft .NET Framework version 4.7.03056)
⦁ MySQL Community Server 8.0.11
⦁ MySQL Connector/C++ version 8.0.11
(Boost Libraries NOT REQUIRED)

Tutorial Steps
2. Using MySQL Installer install:
a. MySQL Community Server 8.0.11
b. MySQL Connector/C++ version 8.0.11
3. Update the relevant include and lib directories in Visual Studio Community 2017
a. C:\Program Files\MySQL\Connector C++ 1.1\include
b. C:\Program Files\MySQL\MySQL Server 8.0\include
c. C:\Program Files\MySQL\Connector C++ 1.1\lib\opt
d. C:\Program Files\MySQL\MySQL Server 8.0\lib
4. Code, build, run
to the executable directory
C:\Program Files\MySQL\MySQL Server 8.0\bin to the executable directory

SQL Statements to create test database, table and data:
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE test (id int, name varchar(32), score int);
INSERT INTO test (id, name, score) VALUES (1, "Marianne", 89);
INSERT INTO test (id, name, score) VALUES (2, "Jimmy", 62);
INSERT INTO test (id, name, score) VALUES (3, "Ling", 78);
SELECT * FROM test;

Simple C++ Windows Console Source Code to connect to MySQL Server:
Рекомендации по теме
Комментарии
Автор

for those visiting this video in current date here is some things to note:

1: the download link for the CPP file doesnt work, just write it manually by looking at the code you can see fully between 10:18 and 10:19.

2: in his code he includes his own header file on line 4, leave that line out, you don't need it for this example program.
3: at 19:55 he copies " libeay32.dll " and " ssleay32.dll ", if you can't find them, you need to copy " libcrypto-1_1-x64.dll " and " libssl-1_1-x64.dll " instead, all the other steps are the same.

These are the only differences from the original video, if you take note of these changes then it should work perfectly.

Zephode
Автор

I have spent literally two days trying to connect to mysql database.
Thank you a lot.
This video gave me a chance not to be a mcdonald's worker.

hirb
Автор

This really is the best tutorial for linking c++ development to SQL. I struggled with the library files on other tutorials but finally managed to get it because of this great video. Just perfect explanations on everything. So fortunate to have content like this for free.

aj_art
Автор

You're a life saver. I don't know why most software has to be so difficult to set up...

amp
Автор

I've been searching for an article/video on this for hours. Thank you!

MrSuperdude
Автор

Mate, thanks to you and your tutorial I am now able to do my school project. I have searched many tutorials(how to connect c++ with database), but all of them was too complicated for me. Your solution is the first one that work as it should. You have my gratitude. Sub and like :)

arheiss
Автор

I tried it today with today date newest mysql server and VS19 on Win 10 Pro x64.


I had to use the c++ connector version 1.11 (newest version would be 8.0, but I didn't know how it work with it) and the files to copie are "libcrypto-1_1-x64" and "libssl-1_1-x64" insteat of libeay32.dll and ssleay32.dll. Then it works fine.
Big THANK YOU!
I tried it for days, until your video helps me.


PS: your testfile is corrupt or something, I had to write the code by hand, from your video.

Erimioa
Автор

For people trying to use C++ connector 8 and VS2019, follow the steps the same but
instead of step 3.c, use C:\Program Files\MySQL\MySQL Connector C++ 8.0\lib64\vs14 as the directory

I didn't need step 4.b. at all

afkafkafk
Автор

Worked perfectly fine for me. What I would like to add is that i had no problems implementing this in both, debug and release mode with exactly the same settings.

julianwittmann
Автор

thanks a lot bro i spend 3 days searching for a solution and i find it here with simple explanation .. im glad that i find this video

Akashi_
Автор

Thanks, took me all day browsing and watching youtube trying to get this to work. Mysql is connected : )

detroilions
Автор

3 years later and it is still working. thank you!!!

nuyoluyo
Автор

Thank you!
After messing around with Visual Studio 2019 and MySQL Connector C++ I tried everything in this tutorial step by step. Finally my console application reads my little datatable fom MySQL.
I needed to include the full path and name of the additional dependencies.
My configuration:
Windows 10
Visual Studio Community 2019
.NET 4.8.03752
MySQL 8.0.23
Connector C++ 8.0.23

henninghilgers
Автор

THANK YOU SO MUCH FOR THIS KIND OF VIDEO IS EXISTING!!! It really helps me a lot in setting up database for my project in c++

erjei
Автор

Liked and subscribed. Solved my problem i've been struggling with for a week.

stagetired
Автор

nice explanation still works in 2024 but in including lib files of connector i did not include /opt in path so for anyone having issue try this too

sarkkk
Автор

Finally a tutorial that solved my problems

vlad
Автор

YOU ARE THE BEST!!! THANK YOU!!
You literally saved my... doesn't matter, you saved me, thank you!!!! /sends beams of gratitude ~~~~/

ansyona
Автор

Awesome video man! Helped me out :D Subbed ;)

null
Автор

You are a saviour for I, a total noob. Thank you a bunch.

tambow