Ubuntu 16.04.4安装MySQL的Error汇总

一. 安装阶段

在ubuntu上安装MySQL的步骤:

1. sudo apt-get install mysql-server

2. sudo apt-get install mysql-client

3. sudo apt-get install libmysqlclient-dev

1.1. 执行命令:sudo apt install mysql-server

错误提示:

Preconfiguring packages ...
dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 2 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin

E: Sub-process /usr/bin/dpkg returned an error code (2)

解决方法:

1. ldconfig

1)执行find / -name ldconfig,查找当前的路径:

root@iZwz99lf7ill1k4n6cout2Z:/mysql/mysql-8.0.11# find / -name ldconfig
/var/lib/dpkg/triggers/ldconfig
/var/cache/ldconfig
/srv/sbin/ldconfig

2)将/var/cache/ldconfig 或 /srv/sbin/ldconfig的ldconfig文件拷贝到/usr/sbin,并执行命令修改文件权限:

root@iZwz99lf7ill1k4n6cout2Z:/mysql/mysql-8.0.11# cd /usr/sbin
root@iZwz99lf7ill1k4n6cout2Z:/usr/sbin# chmod +x ldconfig
root@iZwz99lf7ill1k4n6cout2Z:/usr/sbin# ls -l ldconfig
-rwxr-xr-x 1 root root 387 Jun  7 22:34 ldconfig

2. start-stop-daemon

1)执行find / -name ldconfig,查找当前的路径:

root@iZwz99lf7ill1k4n6cout2Z:/mysql/mysql-8.0.11# find / -name ldconfig
/srv/sbin/start-stop-daemon

2)将/srv/sbin/start-stop-daemon 的start-stop-daemon文件拷贝到/usr/sbin,并执行命令修改文件权限:

root@iZwz99lf7ill1k4n6cout2Z:/mysql/mysql-8.0.11# cd /usr/sbin
root@iZwz99lf7ill1k4n6cout2Z:/usr/sbin# chmod +x start-stop-daemon
root@iZwz99lf7ill1k4n6cout2Z:/usr/sbin# ls -l start-stop-daemon

-rwxr-xr-x 1 root root 32528 Jun  7 22:38 start-stop-daemon

 

1.2. 执行指令:sudo apt-get install libmysqlclient-dev

错误提示:

Processing triggers for libc-bin (2.23-0ubuntu5) ...
/usr/sbin/ldconfig: 16: exec: /sbin/ldconfig.real: not found
/usr/sbin/ldconfig: 16: exec: /sbin/ldconfig.real: not found
dpkg: error processing package libc-bin (--unpack):
 subprocess installed post-installation script returned error exit status 127
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
 libc-bin

E: Sub-process /usr/bin/dpkg returned an error code (1)

 

解决方法:

1. ldconfig.real

1)执行find / -name ldconfig.real,查找当前的路径:

root@iZwz99lf7ill1k4n6cout2Z:/mysql/mysql-8.0.11# find / -name ldconfig.real
/srv/sbin/ldconfig.real

2)在根目录新建文件夹sbin,将/srv/sbin/ldconfig.real的ldconfig.real文件拷贝到/sbin,并执行命令修改文件权限:

root@iZwz99lf7ill1k4n6cout2Z:/mysql/mysql-8.0.11# cd /sbin
root@iZwz99lf7ill1k4n6cout2Z:/sbin# chmod +x ldconfig.real
root@iZwz99lf7ill1k4n6cout2Z:/sbin# ls -l ldconfig.real
-rwxr-xr-x 1 root root 996512 Jun  7 23:07 /sbin/ldconfig.real

 

最后,安装完毕后,执行命令查询MySQL安装成功与否,执行命令:sudo nestat -tap | grep mysql

root@iZwz99lf7ill1k4n6cout2Z:/mysql/mysql-8.0.11# netstat -tap | grep mysql
tcp        0      0 localhost:mysql         *:*                     LISTEN      3***7/mysqld  

 

二 编译阶段

错误提示:

root@iZwz99lf7ill1k4n6cout2Z:/home/program/db# g++ -Wall  mysql_demo.cpp -o mysql_test -lmysqlclient
In file included from /usr/include/mysql/mysql.h:81:0,from mysql_demo.cpp:1:
/usr/include/mysql/mysql_com.h:1011:42: fatal error: mysql/udf_registration_types.h: No such file or directory

compilation terminated.

解决方法:

2.1 执行find / -name udf_registration_types.h,查找到当前的路径:

root@iZwz99lf7ill1k4n6cout2Z:/home/program/db# find / -name udf_registration_types.h

/usr/include/mysql/mysql/udf_registration_types.h

2.2 root@iZwz99lf7ill1k4n6cout2Z:/home/program/db# g++ -Wall  mysql_demo.cpp -o mysql_test -lmysqlclient -I/usr/include/mysql/mysql/udf_registration_types.h,还是报错:fatal error: mysql/udf_registration_types.h: No such file or directory

2.3 最终将udf_registration_types.h拷贝到上一层文件夹,即/usr/include/mysql,才成功编译通过。

 

 

 

 

 

 

 

 

你可能感兴趣的:(MySQL)