mysql 在 raspberryPi 上安装连接器 c++

mysql connector c++ install on raspberryPi

我想在我的 raspberry Pi 上设置 connector/c++ 以访问 mysql 数据库。一开始我试过:

sudo apt-get install libmysqlcppconn-dev

安装成功,但出现错误:

ERR: MySQL_Connection::setReadOnly() (MySQL error code: 0, SQLState:  )

这是我正在使用的 cppconn 版本附带的,如此处所述:MySQL Connector for C++ | MySQL_Connection::setReadOnly() exception on setSchema

当我检查时:

sudo apt-cache show libmysqlcppconn-dev

它说 "version: 1.1.0-4"

然后我尝试从源安装最新的包: https://dev.mysql.com/downloads/connector/cpp/ 位于 ->Source Code -> Generic Linux (Architecture Independent), Compressed TAR Archive

我下载并执行了 "tar xvzf mysql-....",一切正常。但是当我尝试用

构建它时
cmake .

我收到错误:

CMake Warning (dev) in CMakeLists.txt:
  Syntax Warning in cmake code at

/home/pi/quadro/mysql-connector/CMakeLists.txt:114:24

Argument not separated from preceding token by whitespace.
  This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
  Syntax Warning in cmake code at

/home/pi/quadro/mysql-connector/CMakeLists.txt:114:54

Argument not separated from preceding token by whitespace.
  This warning is for project developers.  Use -Wno-dev to suppress it.

-- mysql_config was found /etc/mysql
CMake Error at FindMySQL.cm:165 (MESSAGE):
  mysql_config wasn't found, -DMYSQL_CONFIG_EXECUTABLE=...
Call Stack (most recent call first):
  CMakeLists.txt:55 (INCLUDE)


CMake Error at FindMySQL.cm:167 (MESSAGE):
  Cannot find MySQL.  Include dir: MYSQL_INCLUDE_DIR-NOTFOUND library dir:
  cxxflags:
Call Stack (most recent call first):
  CMakeLists.txt:55 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/home/pi/quadro/mysql-connector/CMakeFiles/CMakeOutput.log".

我知道这意味着,它找不到 mysql_config,但我也不知道如何告诉它文件在哪里,也不知道文件实际在哪里。

所以请帮助我。我受够了。

非常感谢。

编辑:

我尝试手动安装最新的软件包,我从以下位置下载:

https://packages.debian.org/jessie/armhf/libmysqlcppconn-dev/download

sudo dpkg -i libmysqlcppconn7_1.1.3-6_armhf.deb
sudo dpkg -i libmysqlcppconn-dev_1.1.3-6_armhf.deb

现在我得到:

$ sudo apt-cache show libmysqlcppconn-dev
Package: libmysqlcppconn-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 3213
Maintainer: Debian MySQL Maintainers <pkg-mysql-    maint@lists.alioth.debian.org>
Architecture: armhf
Source: mysql-connector-c++
Version: 1.1.3-6
Depends: libboost-dev, libmysqlcppconn7 (= 1.1.3-6)
Description: MySQL Connector for C++ (development files)
 MySQL Connector/C++ is a MySQL database connector for C++.
 .
 It mimics the JDBC 4.0 API.
 .
 This package contains the development files (headers, static library).

Package: libmysqlcppconn-dev
Source: mysql-connector-c++
Version: 1.1.0-4
Architecture: armhf
Maintainer: Debian MySQL Maintainers <pkg-mysql-    maint@lists.alioth.debian.org>
Installed-Size: 3382
Depends: libboost-dev, libmysqlcppconn5 (= 1.1.0-4)
Homepage: http://forge.mysql.com/wiki/Connector_C++
Priority: optional
Section: libdevel
Filename: pool/main/m/mysql-connector-c++/libmysqlcppconn-dev_1.1.0-    4_armhf.deb
Size: 602550
SHA256: 286b6bf2ef3eb05dc8660a31780dd9af65c06f7d0d675257636281b2de056e15
SHA1: e53eeb1cf70c7522f557bbb6cbf0a753c6788fbb
MD5sum: 8770d029c21d086a48279c1f6e92f4a6
Description: MySQL Connector for C++ (development files)
 MySQL Connector/C++ is a MySQL database connector for C++.
 .
 It mimics the JDBC 4.0 API.
 .
 This package contains the development files (headers, static library).

这是好事还是坏事?

您需要安装 MySQL 客户端库开发文件:

apt-get install libmysqlclient-dev

尝试并确保安装所有依赖项的更简单方法是要求 apt 为它的打包版本安装所有构建依赖项:

apt-get build-dep libmysqlcppconn-dev

libmysqlclient-dev 软件包不再存在。估计改名了所以要安装 c++ 连接器,有这个新包:

sudo apt install libmysql++-dev