ITPub博客

首页 > Linux操作系统 > Linux操作系统 > mysql5.5安装

mysql5.5安装

原创 Linux操作系统 作者:wang_0720 时间:2013-11-06 14:33:05 0 删除 编辑
mysql5.5后相对以前的版本有个很大的改变,5.5后采用cmake编译,并且innodb作为默认的存储引擎,replication采用半同步 复制。和以前的异步复制相比,在极端的情况下数据的一致性有了很大的保证。下面的脚本只是对mysql5.5的安装做了简要的说明。
#!/bin/bash
#Author: Andy
#Time: 20130905
#./my5install.sh
GROUP=mysql
USER=mysql
PORT=3306
VERSION=5.5.22
CVERSION=2.8.7
FILE_PATH=/root/mysql
MYSQL_BASE=/usr/local/mysql
DATA_HOME=/var/lib/mysql

cat /etc/group|grep "${GROUP}">/dev/null
if [ $? -ne 0 ];then
 
       groupadd ${GROUP}
fi

id mysql >/dev/null 2>&1
if [ $? -ne 0 ];then
        useradd -g ${GROUP} ${USER}
fi

ls ${FILE_PATH} |grep -w "^mysql-${VERSION}$">/dev/null
if [ $? -ne 0 ];then
        tar -zxvf mysql-${VERSION}.tar.gz
fi
#install cmake
cmakeinst()
{
cmake -version>/dev/null 2>&1
if [ $? -ne 0 ];then
        tar -zxf cmake-${CVERSION}.tar.gz
fi
cd ${FILE_PATH}/cmake-${CVERSION}
make
make intall
}

configure()
{
cd ${FILE_PATH}/mysql-${VERSION}
cmake   -DCMAKE_INSTALL_PREFIX=${MYSQL_BASE} \
        -DSYSCONFDIR=/etc \
        -DMYSQL_DATADIR=${DATA_HOME} \
        -DMYSQL_TCP_PORT=${PORT} \
        -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
        -DMYSQL_USER=${USER} \
        -DDEFAULT_CHARSET=utf8 \
        -DEXTRA_CHARSETS=all \
        -DDEFAULT_COLLATION=utf8_general_ci \
        -DWITH_READLINE=1 \
        -DWITH_SSL=system \
        -DWITH_EMBEDDED_SERVER=1 \
        -DENABLED_LOCAL_INFILE=1 \
        -DWITH_INNOBASE_STORAGE_ENGINE=1 \
        -DWITH_MYISAM_STORAGE_ENGINE=1 \
        -DWITH_PARTITION_STORAGE_ENGINE=1 \
        -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
        -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
        -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
        -DWITH_EXAMPLE_STORAGE_ENGINE=1
}
makein()
{
cd ${FILE_PATH}/mysql-${VERSION}
make
make install
}
setup()
{
cp ${MYSQL_BASE}/support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
sed -i '/storage-engine/ s/MYISAM/INNODB/' /etc/my.cnf
sed -i '/rehash/ s/no-auto-rehash/auto-rehash/' /etc/my.cnf
cp ${MYSQL_BASE}/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chown -R ${USER} ${MYSQL_BASE}
chgrp -R ${GROUP} ${MYSQL_BASE}
}
initial()
{
${MYSQL_BASE}/scripts/mysql_install_db \
        --defaults-file=/etc/my5.cnf \
        --basedir=${MYSQL_BASE} \
        --datadir=${DATA_HOME} \
        --user=${USER}
chown -R root ${MYSQL_BASE}
chown mysql.mysql -R ${DATA_HOME}
${MYSQL_BASE}/bin/mysqld_safe \
        --defaults-file=/etc/my5.cnf \
        --basedir=${MYSQL_BASE} \
        --datadir=${DATA_HOME} \
        --user=${USER} &

cat /etc/profile|grep mysql>/dev/null
if [ $? -ne 0 ];then
echo "export PATH=\$PATH:${MYSQL_BASE}/bin" >>/etc/profile
fi
source /etc/profile
}
#============================
cmakeinst
configure
makein
setup
initial

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27181165/viewspace-775842/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 打印“金字塔”
请登录后发表评论 登录
全部评论

注册时间:2013-11-05

  • 博文量
    111
  • 访问量
    907827