linux下编译安装mysql

准备工作

 

1.虚拟机上运行的centos6.6操作系统

2.网络能连接外网

 

安装步骤

1.检测系统是否安装mysql

 

[root@localhost mysql-5.6.12]# rpm -qa|grep mysql
mysql-libs-5.1.73-3.el6_5.x86_64

   或

[root@localhost mysql-5.6.12]# rpm -qa | grep -i libs | grep -i mysql 
mysql-libs-5.1.73-3.el6_5.x86_64

  

 

2.发现系统预安装的mysql-libs包,那么卸载它,扫清障碍

[root@localhost mysql-5.6.12]# rpm -e mysql-libs
error: Failed dependencies:
        libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64
        libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64
        mysql-libs is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64

 发生错误,提示需要postfix,所以有了

[root@localhost mysql-5.6.12]# rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64
[root@localhost mysql-5.6.12]# rpm -qa | grep -i libs | grep -i mysql 
[root@localhost mysql-5.6.12]# 

 清除干净了。

3.先安装,编译需要的包、工具

yum -y install make gcc-c++ cmake bison-devel  ncurses-devel

4.cmake

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

cmake结果:

-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
CMake Warning (dev) in sql/CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "mysqld" has an INTERFACE_LINK_LIBRARIES property which differs from
  its LINK_INTERFACE_LIBRARIES properties.

  INTERFACE_LINK_LIBRARIES:

    -lpthread;sql;binlog;rpl;master;slave;sql;mysys;mysys_ssl

  LINK_INTERFACE_LIBRARIES:

    rt

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    WITH_MEMORY_STORAGE_ENGINE
    WITH_READLINE


-- Build files have been written to: /usr/mingSoft/mysql-5.6.12
[root@localhost mysql-5.6.12]# 

 5.安装

make && make install

 编译的参数可以参考http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

 

 

 

 

你可能感兴趣的:(linux)