• CentOS6.5源码安装mysql-5.5.21


    本文参考自 http://www.cnblogs.com/ShanFish/p/6531365.html,但不局限于它。

    一. 卸载旧版本

    1.检查是否安装mysql组件
    # rpm -qa | grep mysql
    
    2.如果有,就卸载
    # rpm -ev mysql-libs-5.1.71-1.el6.x86_64
    # rpm -ev mysql-libs-5.1.71-1.el6.x86_64 --nodeps  //强力删除
    
    3.删除相关目录
    # whereis mysql
    # find / -name 'mysql'
    
    //在卸载掉第2步的mysql组件后,下面的目录应该就被删除了(如果还存在的话,手动删除)
    # rm -rf /usr/share/mysql
    # rm -rf /usr/lib64/mysql

    二. 编译安装

    1.安装编译所需的软件包

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

    2.下载解压
    终端的文件下载地址我也没有,可以去这个网址 http://download.csdn.net/download/lhat_7/9863714 下载压缩包

    tar xvf mysql-5.5.21.tar.gz
    cd mysql-5.5.21

    3.编译安装

    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

    报错1:

    -- MySQL 5.5.21
    Warning: Bison executable not found in PATH
    -- 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;mysys
    
      LINK_INTERFACE_LIBRARIES:
    
        rt
    
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- Generating done
    -- Build files have been written to: /mnt/mysql-5.5.21
    View Code

    百度之后得到答案  yum install bison 

    重新编译前要清缓存

    make clean
    rm -f CMakeCache.txt
    rm -rf /etc/my.cnf

    再次编译有报错2:

    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;mysys
    
      LINK_INTERFACE_LIBRARIES:
    
        rt
    
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- Generating done
    -- Build files have been written to: /mnt/install_package/mysql-5.5.21
    View Code

    解决方法:没找到解决方法(我没管它,直接下一步了)

    make && make install

    这是一个漫长的过程,等待...

    三. 配置MySQL

    1. 设置权限

    查看是否有mysql用户和用户组

    cat /etc/passwd
    cat /etc/group

    如果没有就添加用户和用户组

    groupadd mysql
    useradd -g mysql mysql

    修改 /usr/local/mysql 权限

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

    2.初始化mysql

    执行初始化配置脚本,创建系统自带的数据库和表

    cd /usr/local/mysql
    scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

    3.添加mysql服务

    如果/etc目录下之前存在my.cnf文件,将其重命名作为备份

    mysql服务启动时,会优先在 /etc 目录下查找 my.cnf

    cp support-files/mysql.server /etc/init.d/mysql
    chkconfig mysql on
    service mysql start

    4.配置mysql用户

    把 /usr/local/mysql/bin 目录添加到PATH里,这样在任何地方都能直接调用该目录下的命令了。

    vim /etc/profile
    //在 /etc/profile 的末尾添加 
    export PATH=$PATH/usr/local/mysql/bin
    //关闭文件,运行下面的命令,使配置立即生效
    source /etc/profile

    mysql启动成功后,root用户默认没有密码,我们需要为它设置密码

    mysqladmin -uroot -p password <new_password>

    最后使用密码登录

    【 参考随笔】

    CentOS 6.4下编译安装MySQL 5.6.14

    MySQL CMake参数说明手册

  • 相关阅读:
    java用户角色权限设计
    六种方式实现hibernate查询,及IDE推荐
    SSH远程会话管理工具
    Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置
    Linux 下JDK安装
    linux下FTP的工具和使用以及rpmReadSignature failed错误
    不用FTP使用SecureCRT上传下载文件,并解决rz、sz command not found异常
    hibernate通过数据库表反向生成实体类
    解决vmware 桥联 再次使用联不上网的问题
    log4j详解与实战
  • 原文地址:https://www.cnblogs.com/lhat/p/6958212.html
Copyright © 2020-2023  润新知