ubuntu18.04 安装的mysql5.7怎么找不到库啊?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu18.04 安装的mysql5.7怎么找不到库啊?相关的知识,希望对你有一定的参考价值。

数据库能完好使用,但是我要用C语言去操作数据库,但当我去找libmysqlcilent 和mysql.h的时候根本就没有,全局搜索都没有,请教大神怎么回事!

参考技术A

你需要重新安装那些被 “dpkg warning” 缺失的软件。

尝试修复:

    强制修复

    1   sudo apt-get -f install   

    2. 如果上一步无效。你需要过滤出被 dpkg warning 的软件,然后执行下面的命令,重新挨个安装

    1   sudo apt-get install --reinstall "package name"   

    用 warning 中具体的软件名代替上面命令中的 package name

    比如:dpkg: warning: files list file for package 'libcap2:amd64' missing; assuming package has no files currently installed

    重新安装的命令就是:

    1   sudo apt-get install --reinstall "libcap2:amd64"   

    如果想偷懒,只需执行下面一行命令,原理同上——过滤出被 dpkg warning 的软件,然后安装

    1   sudo -i; for package in $(apt-get upgrade 2>&1 | grep "warning: files list file for package '" | sed -rn 's/.*package '\\''([^'\\'']+).*/\\1/p'); do apt-get install --reinstall "$package"; done   

参考技术B 使用如下命令,即可安装mysql的库
sudo apt install libmysqlclient-dev

ubuntu 18.418.4安装完成后的库和头文件路径分别为:
库文件路径:/usr/lib/x86_64-linux-gnu
头文件路径:/usr/include/mysql
编译mysql.c文件需要添加,头文件路径,库文件路径,gcc命令如下:
gcc mysql.c -o mysql -I/usr/include/mysql -L/usr/lib/x86_64-linux-gnu -lmysqlclient
如果上述gcc命令执行有错误,请使用以下命令
gcc mysql.c -o mysql -I/usr/include/mysql -L/usr/lib/x86_64-linux-gnu -lmysqlclient -ldl -lstdc++ -lm -lrt -lpthread
参考技术C 用locate 或者whereis 定位文件

Ubuntu 怎么安装mysql5.7

先安装好操作系统   在Mysql官网上下载最新版的Ubuntu Linux专用的Mysql。我这里下载的是:mysql-server_5.7.11-1ubuntu14.04_amd64.deb-bundle.tar。   解压文件 命令为:tar -xvf mysql-server_5.7.11-1ubuntu14.04_amd64.deb-bundle.tar.   解压开来后,一共有11个deb包,用sudo dpkg -i [包名]命令逐个安装,因为包与包中间存在依赖关系,这里安装有个先后顺序。   我的安装的顺序是:   1.mysql-common_5.7.11-1ubuntu14.04_amd64.deb   2.libmysqlclient20_5.7.11-1ubuntu14.04_amd64.deb   3.libmysqlclient-dev_5.7.11-1ubuntu14.04_amd64.deb   4.libmysqld-dev_5.7.11-1ubuntu14.04_amd64.deb   5而后需要安装一个依赖包叫libaio1,命令为sudo apt-get intall libaio1;   而后继续:   5.mysql-community-client_5.7.11-1ubuntu14.04_amd64.deb   6.mysql-client_5.7.11-1ubuntu14.04_amd64.deb   7.mysql-community-source_5.7.11-1ubuntu14.04_amd64.deb   6   这里需要再安装一个依赖包叫libmecab2,安装好后,继续安装最后一个:   8.mysql-community-server_5.7.11-1ubuntu14.04_amd64.deb   安装过程中需要设置数据库密码。   到这里,所有的已经安装完毕。输入Mysql -uroot-p可以登陆数据库了。 参考技术A   sudo apt-get update
sudo apt-get upgrade
apt-get install libaio1
(apt-get install mysql-server mysql-client自动安装会装上5.5)

sudo groupadd mysql
sudo useradd -r -g mysql mysql

cd /usr/local/src
sudo wget mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar

sudo tar -xvf mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
这一步骤会提示让你输入root密码,后期可改,随便输个。
sudo dpkg -i mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.6-m16-1ubuntu12.04_amd64.deb

cd /usr/local/
sudo ln -s /var/lib/mysql /usr/local/mysql
sudo mkdir /usr/local/mysql/data
sudo chown -R mysql. /usr/local/mysql/data

修改密码
sudo /usr/bin/mysqladmin -u root password

登录
sudo /usr/bin/mysql -u root -p [可选数据库名称]
远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.10.40.54' IDENTIFIED BY '123456' WITH GRANT OPTION;

远程连接某表 : 创建username用户,可远程访问app数据库下user表,具有读、更新权限

grant select,update on app.user to username@‘%’ identified by '123456';

open_files_limit = 10240
back_log = 258
max_connections = 5000
max_connect_errors = 716
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 8M
join_buffer_size = 1M
thread_cache_size = 300
query_cache_type=1
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
thread_stack = 192K
tmp_table_size = 258M
max_heap_table_size = 258M
key_buffer_size = 512M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
wait_timeout=1814400
bulk_insert_buffer_size = 64M
innodb_buffer_pool_size = 8000M
innodb_buffer_pool_instances=32
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 2048M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 20000
innodb_io_capacity_max = 40000

查看连接数

show variables like '%max_connections%'
这时应该为5000,说明配置已生效
参考技术B sudo apt-get update
sudo apt-get upgrade
apt-get install libaio1
(apt-get install mysql-server mysql-client自动安装会装上5.5)

sudo groupadd mysql
sudo useradd -r -g mysql mysql

cd /usr/local/src
sudo wget mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar

sudo tar -xvf mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
这一步骤会提示让你输入root密码,后期可改,随便输个。
sudo dpkg -i mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.6-m16-1ubuntu12.04_amd64.deb

cd /usr/local/
sudo ln -s /var/lib/mysql /usr/local/mysql
sudo mkdir /usr/local/mysql/data
sudo chown -R mysql. /usr/local/mysql/data

修改密码
sudo /usr/bin/mysqladmin -u root password

登录
sudo /usr/bin/mysql -u root -p [可选数据库名称]
远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.10.40.54' IDENTIFIED BY '123456' WITH GRANT OPTION;

远程连接某表 : 创建username用户,可远程访问app数据库下user表,具有读、更新权限

grant select,update on app.user to username@‘%’ identified by '123456';

open_files_limit = 10240
back_log = 258
max_connections = 5000
max_connect_errors = 716
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 8M
join_buffer_size = 1M
thread_cache_size = 300
query_cache_type=1
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
thread_stack = 192K
tmp_table_size = 258M
max_heap_table_size = 258M
key_buffer_size = 512M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
wait_timeout=1814400
bulk_insert_buffer_size = 64M
innodb_buffer_pool_size = 8000M
innodb_buffer_pool_instances=32
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 2048M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 20000
innodb_io_capacity_max = 40000

查看连接数

show variables like '%max_connections%'
这时应该为5000,说明配置已生效

以上是关于ubuntu18.04 安装的mysql5.7怎么找不到库啊?的主要内容,如果未能解决你的问题,请参考以下文章

Unbuntu18.04通过apt源方式安装mysql5.7.22

Ubuntu18.04安装mysql5.7

Ubuntu18.04安装、卸载MySQL

Ubuntu18.04 安装mysql8.0

Ubuntu 18.04 安装MySQL

Ubuntu18.04 修改Mysql5.7默认root密码