Coder Social home page Coder Social logo

connecting-mysql-to-cpp's Introduction

Connecting MySQL database to C++ using Visual Studio 2019

Downloading, installing and setting up MySQL

  1. Download and install MySQL installer
  2. Using MySQL installer install MySQL Community Server 8.0.X and MySQL Connector /C++ 1.1.13
  3. 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;

Setting up Visual Studio

  1. Create new console app project
  2. Change Solution Configuration to Release and Solution platform to x64
  3. Right click to your project section and select properties Project-rightclick
  4. Go to C/C++ section and select General C/Cpp-general
  5. 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
  6. Go to Linker section and select General Linker-general
  7. 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
  8. Move to Input in Linker section Linker-input
  9. Select Additional Dependencies and add this libraries mysqlcppconn.lib, libmysql.lib

Coding and building app

  1. Code your app and build
  2. After building go to directory with your executable file and paste there this DLLs
    • libmysql.dll from C:\Program Files\MySQL\MySQL Server 8.0\lib
    • libcrypto-1_1-x64.dll and libssl-1_1-x64.dll from C:\Program Files\MySQL\MySQL Server 8.0\bin
  3. 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

connecting-mysql-to-cpp's People

Contributors

sosaymon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.