mysql-5.6.27源码安装及错误解决办法

回复 收藏

  • 环境:centos6.5.x86_64
  • wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.27.tar.gz
  • yum install -y cmake  当然也可以自己下载源码包安装,为方便就Yum安装了
  • useradd -s /sbin/nologin mysql
  • tar zxvf mysql-5.6.27.tar.gz
  • mkdir -p /data/mysql
  • chown -R mysql:mysql /data/mysql
  • cd mysql-5.6.27
    1. cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0  -DENABLED_LOCAL_INFILE=1
  • 出现错误:
    1. -- Running cmake version 2.8.12.2
    2. -- Could NOT find Git (missing:  GIT_EXECUTABLE)
    3. -- The C compiler identification is unknown
    4. -- The CXX compiler identification is unknown
    5. CMake Error: your C compiler: "CMAKE_C_COMPILER-NOTFOUND" was not found.   Please set CMAKE_C_COMPILER to a valid compiler path or name.
    6. CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    7. CMake Error at cmake/os/Linux.cmake:27 (STRING):
    8.   string sub-command REPLACE requires at least four arguments.
    9. Call Stack (most recent call first):
    10.   CMakeLists.txt:149 (INCLUDE)
    11. CMake Error at cmake/os/Linux.cmake:27 (STRING):
    12.   string sub-command REPLACE requires at least four arguments.
    13. Call Stack (most recent call first):
    14.   CMakeLists.txt:149 (INCLUDE)
    15. -- MySQL 5.6.27
    16. -- Packaging as: mysql-5.6.27-Linux-i686
    17. -- Could NOT find Threads (missing:  Threads_FOUND)
    18. -- Could NOT find Threads (missing:  Threads_FOUND)
    19. -- Check if the system is big endian
    20. -- Searching 16 bit integer
    21. CMake Error at /usr/share/cmake/Modules/TestBigEndian.cmake:44 (message):
    22.   no suitable type found
    23. Call Stack (most recent call first):
    24.   configure.cmake:628 (TEST_BIG_ENDIAN)
    25.   CMakeLists.txt:398 (INCLUDE)
    26. -- Configuring incomplete, errors occurred!
    27. See also "/usr/local/src/mysql-5.6.27/CMakeFiles/CMakeOutput.log".
    28. See also "/usr/local/src/mysql-5.6.27/CMakeFiles/CMakeError.log".

    分析:

    -- Could NOT find Git (missing:  GIT_EXECUTABLE)这项应该缺少git包,yum install -y git

    -- The C compiler identification is unknown

    -- The CXX compiler identification is unknown 这两项缺少gcc和gcc-c++的包,yum install -y gcc gcc-c++

    另外需要rm CMakeCache.txt

    继续

    1. cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
    出现错误:
    1. CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    2. Please set them or make sure they are set and tested correctly in the CMake files:
    3. OPENSSL_INCLUDE_DIR
    4.    used as include directory in directory /usr/local/src/mysql-5.6.27/CMakeFiles/CMakeTmp
    5. CMake Error: Internal CMake error, TryCompile configure of cmake failed
    6. -- Check size of wchar_t - failed
    7. -- Check size of wctype_t
    8. CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    9. Please set them or make sure they are set and tested correctly in the CMake files:
    10. OPENSSL_INCLUDE_DIR
    11.    used as include directory in directory /usr/local/src/mysql-5.6.27/CMakeFiles/CMakeTmp
    12. CMake Error: Internal CMake error, TryCompile configure of cmake failed
    13. -- Check size of wctype_t - failed
    14. -- Check size of wint_t
    15. CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    16. Please set them or make sure they are set and tested correctly in the CMake files:
    17. OPENSSL_INCLUDE_DIR
    18.    used as include directory in directory /usr/local/src/mysql-5.6.27/CMakeFiles/CMakeTmp
    19. CMake Error: Internal CMake error, TryCompile configure of cmake failed
    20. -- Check size of wint_t - failed
    21. -- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
    22. CMake Error at cmake/readline.cmake:85 (MESSAGE):
    23.   Curses library not found.  Please install appropriate package,
    24.       remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
    25. Call Stack (most recent call first):
    26.   cmake/readline.cmake:128 (FIND_CURSES)
    27.   cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
    28.   CMakeLists.txt:409 (MYSQL_CHECK_EDITLINE)
    29. -- Configuring incomplete, errors occurred!
    30. See also "/usr/local/src/mysql-5.6.27/CMakeFiles/CMakeOutput.log".
    31. See also "/usr/local/src/mysql-5.6.27/CMakeFiles/CMakeError.log".
    分析:

    -- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)  缺少ncurses-devel包,yum install -y ncurses-devel

  • rm CMakeCache.txt

  • 通过阅读官方文件http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html,去除选项-DWITH_READLINE=1和-DWITH_SSL=YES

    1. cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0  -DENABLED_LOCAL_INFILE=1
    出现warning:
    1. -- Running cmake version 2.8.12.2
    2. -- MySQL 5.6.27
    3. -- Packaging as: mysql-5.6.27-Linux-x86_64
    4. -- HAVE_VISIBILITY_HIDDEN
    5. -- HAVE_VISIBILITY_HIDDEN
    6. -- HAVE_VISIBILITY_HIDDEN
    7. -- Using cmake version 2.8.12.2
    8. -- Not building NDB
    9. -- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
    10. Warning: Bison executable not found in PATH
    11. -- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
    12. -- CMAKE_BUILD_TYPE: RelWithDebInfo
    13. -- COMPILE_DEFINITIONS: HAVE_CONFIG_H
    14. -- CMAKE_C_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
    15. -- CMAKE_CXX_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
    16. -- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
    17. -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
    18. -- Configuring done
    19. -- Generating done
    20. -- Build files have been written to: /usr/local/src/mysql-5.6.27
    分析:Warning: Bison executable not found in PATH  缺少Bison,yum install -y bison
    1. cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0  -DENABLED_LOCAL_INFILE=1

  • echo $? 是0代表OK

  • make && make install

  • chown -R mysql:mysql /usr/local/mysql/

  • cd /usr/local/mysql/

  • ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql 初始化

  • cp support-files/my-default.cnf /etc/my.cnf

  • cp support-files/mysql.server /etc/init.d/mysqld

  • chmod 755 /etc/init.d/mysqld

  • vim /etc/init.d/mysqld   修改datadir=/data/mysql

  • service mysqld start

  • 成功启动Starting MySQL.. SUCCESS!

2015-12-26 15:54 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: