找不到mysql.h

<mysql/mysql.h> 找不到

通过搜索发现,原因是安装MySQL时只是安装了MySQL的服务器和MySQL的客户端,没有安装 libmysqlclient-dev

apt 能指定版本号安装,于是 sudo apt install zlib1g=1:1.2.11.dfsg-0ubuntu2
解决办法:

  1. 图形界面操作:直接在软件中心输入MySQL database development files或者libmysqlclient-dev,点击安装
  2. 命令行下:输入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就成功了。

所以这东西是讲道理的,如果你不会,那么说明学习的机会来了。会了分分钟就解决这个问题。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值