c++使用mysql-connector连接mysql(linux centos6.5)

时间:2021-10-02 02:35:23
我的PC:centos6.5  64位
安装mysql5.6方法:
1,wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
2,rpm -ivh mysql-community-release-el6-5.noarch.rpm
3,yum install mysql-server
4,/etc/init.d/mysqld start
5,mysql -u root(登录数据库,默认密码为空)
安装mysql-connector-c++-1.1.5********.tar.gz
下载后解压即可,然后把include下所有都拷贝到/usr/include
把lib下所有都拷贝到/usr/lib
测试方法:http://www.linuxidc.com/Linux/2013-01/77763.htm
如果遇到错误:error while loading shared libraries: libmysqlcppconn.so.7: cannot open shared object file: No such file or directory
解决办法:export LD_LIBRARY_PATH="/usr/lib"
我的libmysqlcppconn.so.7在/usr/lib下
遇到错误:在connect时段错误,我的错误原因是编译器的问题,尝试用g++ 4.8编译后运行
允许其他IP访问mysql:
1,登录mysql
2,GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
3,flush privileges;