


MYSQL *connect //database connection variable MYSQL_RES* Perform_Query(MYSQL* connection, const char* query)Ĭout << "MySQL query error : %s\n" << mysql_error(connection) << endl After doing all these things, write this code on your cpp file of your Project inside Code Blocks: where you can see *.cpp and *.cbp fileġ0. Copy it and paste it in these locations :Ģ. Now with Explorer, goto "C:\Program Files (x86)\MySQL\MySQL Server 5.7\lib", and look for the file Add these folder -Ĭ:\Program Files (x86)\MySQL\MySQL Server 5.7\includeĩ. Goto Build Options -> Search directories tab. (Click No if asked for Relative Path, change the path as required if you installed the MySQL Server in some different place that mentioned above.)Ĩ. Add -Ĭ:\Program Files (x86)\MySQL\MySQL Server 5.7\lib\libmysql.libĬ:\Program Files (x86)\MySQL\MySQL Server 5.7\lib\mysqlclient.lib Goto Build Options -> Linker Settings tab. Now run Code Blocks, start a new Console Application of C++.ħ. On the last step here, you would see some list of procedures and Execute button, click on execute, after completing ( or getting failed to start Server ), close and finish the setup.Ħ.

Change it to some other number, such as 3307 (as MySQL from Xampp runs in 3306 by default).ĥ. After completing download and installation, you would be asked to write Port number in which MySQL will run. Next run MySQL Installer (mysql-installer-web-community-5.7.17.0.msi), and in installation process choose Custom, then add MySQL Server 5.7.17 - X86 ( not all of its components, only check the Development Components and its Client C API library ). To check if Xampp is working correctly, from your Web Browser, go to to see if Welcome text comes or not, it you see Welcome to XAMPP then its fine.ģ. Open Xampp Control Panel and click Start button for Apache and MySQL modules, wait until they start. Keep Xampp on its usual path (C:\xampp).Ģ. We need Xampp because it gives support of MySQL server, you can manage your database with it using integrated PHPmyAdmin.Īgain we need MySQL Installer to install necessary Header and Lib files to use MySQL on Code Blocks.ġ. From, download Windows (x86, 32-bit), MSI Installer (version 5.7.17, 1.7MB). Connecting Code Blocks C++ with MySQL and Xamppġ.
