Database Connection in C++ - MySQL or MariaDB

preview_player
Показать описание
Time to connect to a database using pure C++, no codeblocks, no special IDEs, no QT, just C++ and MySQL.

NOTE: You need to have libmysqlclient-dev installed if you're using MySQL (linux)

Note: Remember to modify if you don't use MariaDB

Timestams:
00:00 - Intro
00:28 - Rant
01:24 - Example Program
02:14 - What You Need
03:06 - Creating the files
04:00 - Template Code
05:25 - Coding Everything
16:30 - The main() Code
24:33 - Running the Code (Info)
26:49 - Fixing Errors
27:18 - Running the Code
27:33 - Outro

Group Chats:

You can contact me on:

Any suggestions? Leave it in the comment section or contact me somewhere else!

Thank you for watching!
Рекомендации по теме
Комментарии
Автор

Of course, if you use MySQL and not Mariadb, then you compile with: g++ main.cpp -o output -L/usr/include/mysql/mysql -lmysqlclient

Stevesteacher
Автор

Thank you so much! I was getting sick of reading data from files, something new to explore is always appreciated <3

shizu-sanuwu
Автор

This has lead to my very first breakthrough in C++ MySQL connection. Thanks a lot

pnamagonya
Автор

Works great. For MySQL + Using Ubuntu 20.04: I had to 'sudo apt-get install libmysqlclient-dev' because I had no 'usr/include/mysql...'

michaelmueller
Автор

Thank you so much for appreciating those of us who also find the codeblox stuff disgusting, and actually going into the code

sethparker
Автор

i really like this, super thankful. I just think it's better when unnecessary background music isn't included.

raginibhayana
Автор

Nice one man.
I'm a UK Year 4 Computer Science student, out of the coding languages I've used, C/C++ is the one I've struggled with most, pointers and references confuse me and all the std:: stuff takes time to get used to.
Great video, I've shared it to a few peeps.

TidusDX
Автор

Thanks!! Very helpful. Love your voice 💅💅💅

ІлляЛеонідовичДубровін
Автор

Thanks! I was getting nowhere with all the changes with MariaDB. Thank You!

scottykne
Автор

I spent a few weeks connecting to oracle and using their OCI coffee and DLLs and lib.

colinmaharaj
Автор

Anyone of you manage to replicate this example on Ubuntu 22 with MySQL?
If not, which Ubuntu releases you use that successfully run this example? Thanks in advance

chieeyeoh
Автор

Just notice if you want to run that connection in a loop, instead of exit(1) when something goes wrong, it is better to add <mysqld_error.h> header and show an informative error message with mysql_error() function that takes the MYSQL* connection as a parameter. If you are using Windows and you have to include the MySQL system path to your IDE cpp compile settings . To be precise, include C:/Program Files/MySQL/MySQL Server 8.0/include" and ${the same}/MySQL Server 8.0/lib". Here you may bump into a problem with the libmysql.dll - if you are using a 32 bit compiler and that file is 64 bit you cannot build the project and vice-versa. Either everything is 64 bit or 32 bit. If you have found it difficult, have a look at a more modern and simplified API offered through the MySQL Connector C++ in cleaner C++ (header file: <mysqlx/xdevapi.h>), have a look at their guide and examples on Github

emoutraspalavras-marloncou
Автор

This is only on the local machine correct? How would I go about making users able to log in from other computers?

russsully
Автор

Very helpful video! I wish he used classes and such bc the way the code looks looks very similar to a code. In other words, I wish he used object-oriented programming principles to connect with the SQL databases since C++ is known for that.

JohnlukeSabile
Автор

How to execute stored procedure in mysql use c++ .

fajarsidik
Автор

Hi, I have undefined reference to my sql functions and i did as you. Any help?

andreidodu
Автор

Hi I did exactly what you did in the tutorial. I can't compile because it can't find the mysql_connection_setup() function.
I commented out the function to test the rest of the code but when I run the program it responds with a segmentation error. Could you help me please?
Ubuntu 22 system.
MySQL DB

JohnnyDrengr
Автор

good man thanks a lot very informative

joanvidal
Автор

MariaDB is a drop-in replacement for MySQL. All code created for MySQL will work on MariaDB.

JV-pukx
Автор

I can't thank you enough for this..

enzycal