Refer to the blog's approach: http://zhmy.michael.blog.163.com/blog/static/861578792012101244715692/
1. Installing Mysql:sudo apt-get Install Mysql-server
2. sudo apt-get install libmysql++-dev
3. Copy lib:
sudo cp/usr/lib/mysql/plugin/usr/lib/-A
4. You can try it.
Create a new CPP file with the following code:
1 #include <iostream> 2 # Include <mysql/mysql.h> using Span style= "color: #0000ff;" >namespace Std; 5 int Main () 6 { 7 mysql_init (&mysql); return 0 10 }
View Code
The library must be added when compiling, the command is as follows:
sudo g++-o test Test.cpp-l/usr/lib/mysql-lmysqlclient-lz
Then./test runs, and this code doesn't do anything, but if the code compiles successfully, then the rest is fine.
If you do not add the following arguments, the Mysql_init error is not found.
Ubuntu under C + + connection MySQL Database