<mysql/mysql.h> 找不到
通过搜索发现,原因是安装MySQL时只是安装了MySQL的服务器和MySQL的客户端,没有安装 libmysqlclient-dev
apt 能指定版本号安装,于是 sudo apt install zlib1g=1:1.2.11.dfsg-0ubuntu2
解决办法:
- 图形界面操作:直接在软件中心输入MySQL database development files或者libmysqlclient-dev,点击安装
- 命令行下:输入
sudo apt-get install libmysqlclient-dev,
输入密码,安装完成后输入whereis mysql.h
则出现/usr/include/mysql,说明mysql.h可以被使用.
whereis
针对PATH
中的路径进行搜索。
find
针对指定路径
进行全局搜索。
问题
在我执行命令的时候 sudo apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libmysqlclient-dev : Depends: libssl-dev (>= 1.1.1-1ubuntu2.1~18.04.5~) but it is not going to be installed
Depends: zlib1g-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
简单来说就是:依赖libssl-dev 没安装-> 依赖zlib1g-dev 没安装
手动安装zlib1g-dev
执行命令的时候 sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-0ubuntu2) but 1:1.2.11.dfsg-2ubuntu1.2 is to be installed
E: Unable to correct problems, you have held broken packages.
现有版本太新了,需要依赖比较旧的版本1:1.2.11.dfsg-0ubuntu2
网上搜索发现apt 还能指定版本号安装
于是,sudo apt install zlib1g=1:1.2.11.dfsg-0ubuntu2
就成功了。
所以这东西是讲道理的,如果你不会
,那么说明学习的机会来了
。会了分分钟就解决这个问题。