topcat 发表于 2013-1-16 00:46:07

CentOS5.2下编译安装Mysql5.1.31

首先更新源配置:

[*]cd /etc/yum.repos.d
[*]mv CentOS-Base.repo  CentOS-Base.repo.save
[*]wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
[*]mv CentOS-Base.repo.5 CentOS-Base.repo
安装fastestmirror:

[*]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...
/usr/local/mysql/libexec/mysqld: unknown option '--skip-federated'
Aborting
/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
 
 
源码编译可真不容易呀!!
 
页: [1]
查看完整版本: CentOS5.2下编译安装Mysql5.1.31