源码编译安装mysql5.1_Shell脚本源码编译安装MySQL5.1.73

#!/bin/bash

#DESCRIPTION 源码安装mysql5.1.73

#NOTICE 安装前需要将源码包放在和脚本同样的路径

## env setting

BASEDIR=/home/mysql

DATADIR=/home/data/mysql

PIDFILE=/home/mysql/mysql.pid

## mysql base env install

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

yum groupinstall base "Development Tools" -y

## create user

groupadd mysql

useradd -r -g mysql mysql

## source package unzip

` -d mysql ` || mkdir mysql && rm -rf mysql && mkdir mysql

tar zxvf mysql-5.1.73.tar.gz -C mysql

mv ./mysql/mysql-5.1.73/* ./mysql/

cd mysql

## mysql install

./configure --prefix=$BASEDIR --datadir=$DATADIR --with-mysqld-user=mysql --with-charset=utf8 --with-extra-charsets=all

make

make install

mkdir -p $DATADIR

chown -R mysql:mysql $BASEDIR

chown -R mysql:mysql $DATADIR

## mysql initial

./scripts/mysql_install_db --datadir=$DATADIR --user=mysql

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

rm -f /etc/my.cnf

cp support-files/my-large.cnf /etc/my.cnf

chmod 755 /etc/init.d/mysqld

sed -inr "s#^basedir=#basedir=$BASEDIR#g" /etc/init.d/mysqld

sed -inr "s#^datadir=#datadir=$DATADIR#g" /etc/init.d/mysqld

sed -inr "s#^pid_file=#pid_file=$PIDFILE#g" /etc/init.d/mysqld

sed -i "/\[mysqld\]/abasedir=$BASEDIR" /etc/my.cnf

sed -i "/\[mysqld\]/adatadir=$DATADIR" /etc/my.cnf

sed -i "/\[mysqld\]/apid_file=$PIDFILE" /etc/my.cnf

## mysql environment variable

export PATH=$PATH:/home/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

source /etc/profile

## service start and enanble

chkconfig mysqld on

/etc/init.d/mysqld start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值