编译安装软件通常会遇到各种问题,尤其是在编译lamp这样的多种软件协同工作时各软件还相互影响,尤其是之前安装的软件会影响后边程序的编译安装,出现这种问题常常是之前安装的软件没有导出库文件和头文件,因而导致后面的软件在安装是需要指定前面安装程序的路径时常常提示找不到文件之类的错误,下面以mysql为例
1、安装开发环境
1
|
yum groupinstall "Development tools" |
2、解决软件包依赖包
安装编译代码需要的包
1
|
yum -y install make gcc-c++ cmake bison-devel ncurses-devel |
下载MySQL 5.6.14
1
2
3
|
wget http: //cdn .mysql.com /Downloads/MySQL-5 .6 /mysql-5 .6.14. tar .gz tar xvf mysql-5.6.14. tar .gz cd mysql-5.6.14 |
3、配置编译并安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
cmake \ -DCMAKE_INSTALL_PREFIX= /usr/local/mysql \ -DMYSQL_DATADIR= /usr/local/mysql/data \ -DSYSCONFDIR= /etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR= /var/lib/mysql/mysql .sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci make && make install |
4、导出库搜索
在 /etc/ld.conf.d/mysql.conf 目录下创建相应的conf文件
1
|
ldconfig - v | grep mysql |
5、导出头文件
1
|
ln -sv /usr/local/mysql/include /usr/include/mysql |
6、导出帮助文件
1
2
|
vim /etc/man .config MANPATH /usr/local/mysql/man |
7、导出二进制路径
1
2
3
|
vim /etc/profile PATH= /usr/local/mysql/bin :$PATH source /etc/profile |
PS:如何使用MySQL yum源来安装更新MySQL相关软件包
MySQL yum库提供了一个简单的和方便的方法来安装和更新MySQL相关的软件包到最新版本。
MySQL yum库文档说明:http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
MySQL yum库支持的平台有:
Red Hat Enterprise Linux 7 / Oracle Linux 7
Red Hat Enterprise Linux 6 / Oracle Linux 6
Red Hat Enterprise Linux 5 / Oracle Linux 5
Fedora 18, 19, and 20
MySQL yum库包括最新的软件包有:
- MySQL 5.6 (GA)
- MySQL 5.7 (Development Release)
- MySQL 5.5 (GA - Red Hat Enterprise Linux and Oracle Linux Only)
- MySQL Workbench
- MySQL Fabric
- MySQL Utilities
- MySQL Connector / ODBC
- MySQL Connector / Python
RHEL7/CentOS7/Oracle linux7:
1
2
|
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm # rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm |
RHEL5/CentOS5/Oracle linux5:
1
|
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el5-5.noarch.rpm |
Fedora
# Fedora20
1
|
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc20-5.noarch.rpm |
#Fedora19
1
|
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc19-5.noarch.rpm |
# Fedora18
1
|
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc18-5.noarch.rpm |