Visual Studio 2013 connects the settings of the MySQL database.

Source: Internet
Author: User

This is from the Internet to find a piece of code, set up a half-day, is really spent half a day (time>6h), no one to help the real egg hurts Ah!

First set up 3 places:

1 , right-click the project, select Properties, Configuration Properties->c/c++-> general, additional include directories, set the path to the include in the MySQL installation directory, mine is C:\ProgramFiles\MySQL\MySQL Server 5.7\include personally feel that this option is in the path of setting mysql.h.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/53/48/wKiom1RltdWjXnVhAAIlLidOj6Y503.jpg "title=" 111. PNG "alt=" wkiom1rltdwjxnvhaaillidoj6y503.jpg "/>

2 , the same way to open the linker, general-and additional library directory, set the MySQL installation directory of the Lib directory, my path is C:\ProgramFiles\MySQL\MySQL Server 5.7\lib a lot of online posts are said to set the OPT directory, but none of it is said to be a Visual Studio version of the issue;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/47/wKioL1Rlto7y3bt0AAKsCtDTttg310.jpg "title=" 111.png "alt=" wkiol1rlto7y3bt0aaksctdtttg310.jpg "/>

3 , linker, input, additional dependencies, Direct Input Libmysql.lib

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/49/wKiom1RltmOCUsqEAAKKK2UWlOQ288.jpg "title=" 111. PNG "alt=" wkiom1rltmocusqeaakkk2uwloq288.jpg "/>

The source code is as follows

consoleapplication7.cpp :  defines the entry point of the console application.   #include "stdafx.h" #include <winsock2.h>//#include <winsock.h> //, which is said to be a high-and low-version relationship # include<iostream> #include <string> #include <mysql.h> #pragmacomment (lib, "Libmysql.lib")// Delete this sentence seems to be no problem, maybe the link is set on the reason it  usingnamespace std; int_tmain () {    //Required data structure      mysql mydata;  //=mysql_init ((mysql*) 0);      // Initialize data structure     if  (Null != mysql_init (&mydata))  {         cout <<  "Mysql_init () succeed" << endl;     }    else {        cout < <  "Mysql_init () failed" << endl;        return - 1;    }     //Initializing Database     if&nbsp (0 == mysql_library_init (0, null, null))  {         cout <<  "Mysql_library_init () Succeed" &LT;&LT;&NBSP;ENDL;&NBSP;&NBSP;&NBSP;&NBSP;}     else {        cout <<  " Mysql_library_init () failed "<< endl;        return -1;     }     //Connection Database     if  (null !=  mysql_real_connect (&mydata,  "127.0.0.1",                                        "root",  "111111",                                         "database_name",3306,                                        null, &NBSP;0)         //Here the address, username, password, database, port can be changed according to their local conditions      {        cout <<  "Mysql_real_connect () Succeed" << endl;    }    else    {         cout <<  "Mysql_real_connect () failed" << endl;         return -1;    }     //operation ...     mysql_close (&mydata);     system ("Pause");     return 0;} 


Here are some of the problems I have encountered:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/53/49/wKiom1Rltp3SKpRQAAL39FkG5zc348.jpg "title=" 111. PNG "alt=" wkiom1rltp3skprqaal39fkg5zc348.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/53/49/wKiom1RlttCgBxeTAAHlhnFdakU425.jpg "title=" 111. PNG "alt=" wkiom1rlttcgbxetaahlhnfdaku425.jpg "/>

Resolution: Pay attention to choose 32-bit or 64-bit platform, my is 64 bit, select x64. (change operation must go to Configuration Manager)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/53/49/wKiom1Rltv6B-0g1AAK7MK5zEE0590.jpg "title=" 111. PNG "alt=" wkiom1rltv6b-0g1aak7mk5zee0590.jpg "/>

The platform options in Configuration Manager select the criteria that match.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/47/wKioL1Rlt6aTMfrcAAJbMZ6-4Sw323.jpg "title=" 111. PNG "alt=" wkiol1rlt6atmfrcaajbmz6-4sw323.jpg "/>


when the following error occurs, remember to MySQL installation directory under the libmysql.dll copy to the project folder below, (that is, the project name of the folder below, began I copied the mysql.h,libmysql.lib and Libmaysql.dll three files, and finally delete to the remaining one)

my libmysql.dll file path is C:\Program files\mysql\mysql Server 5.7\lib;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/53/49/wKiom1Rlt3vhiLeCAADtNdnZAPU531.jpg "title=" 111. PNG "alt=" wkiom1rlt3vhilecaadtndnzapu531.jpg "/>


Running results in the previous diagram:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/53/49/wKiom1Rlt-SxFMH7AAEjX3FPXio053.jpg "title=" 111. PNG "alt=" wkiom1rlt-sxfmh7aaejx3fpxio053.jpg "/>

Beginners,Visual Studio will not be used, there must be a shortage of places, welcome comments ...

Picture cutting is not reliable ah, and then modify it.


This article is from the "An-mo-ka" blog, make sure to keep this source http://anmoka.blog.51cto.com/4151746/1576549

Visual Studio 2013 connects the settings of the MySQL database.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.