CentOS5.2下编译安装Mysql5.1.31

首先更新源配置:

  1. cd /etc/yum.repos.d
  2. mv CentOS-Base.repo  CentOS-Base.repo.save
  3. wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
  4. mv CentOS-Base.repo.5 CentOS-Base.repo

安装fastestmirror:

  1. yum install yum-fastestmirror

安装完这个可以让yum找到最快的源来安装

 

前置条件:

yum install ncurses-devel

如果没有这个在./configure --prefix=/usr/local/mysql 可能会报错,除非你的系统本来就有ncurses-devel

我们可以通过rpm -qa|grep -i ncurses来查看

ncurses-devel-5.5-24.20060715
ncurses-5.5-24.20060715

 

安装mysql:

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql --with-plugins=all  #安装路径 让mysql支持innodb

shell> make

shell> make install

shell> cp support-files/my-medium.cnf /etc/my.cnf

shell> cd /usr/local/mysql

shell> bin/mysql_install_db --user=mysql  #初始化数据库

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &


shell> bin/mysqladmin -u root password yourpassword #设置密码

 

shell> cd /home/topcat/mysql-5.1.31

 

shell> cp support-files/mysql.server /etc/rc.d/init.d/mysqld

 

shell> chkconfig --add mysqd  #添加到服务

上面的这个操作可以参考http://dev.mysql.com/doc/refman/5.1/zh/installing.html#quick-install

在上面的这个过程中的bin/mysql_install_db --user=mysql可能会碰到这样的报错:

Installing MySQL system tables...
[ERROR] /usr/local/mysql/libexec/mysqld: unknown option '--skip-federated'
[ERROR] Aborting
[Note] /usr/local/mysql/libexec/mysqld: Shutdown complete

(这个问题搞了好久)只要将/etc/my.cnf文件中的skip-federated 注释掉即可

 

将mysql加入到环境变量中:

vi /etc/profile.d/mysql_env.sh

在其中加入export PATH=/usr/local/mysql /bin:$PATH

保存并执行source /etc/profile

 

 

源码编译可真不容易呀!!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值