mysql详细安装-一个shell脚本命令即可搞定

在安装之前,先要在linux服务器上面安装yum源和配置网络环境:

一个yum 源配置。如果linux上面没有,需要先配置上。
二个是wget用的是网络源,要求主机在因特网上。打通linux服务器的网络配置环境。
三个是设置防火墙端口3306。

具体命令如下:

#!/bin/bash
echo "-----------------------start install mysql----------------------"
yum -y install gcc gcc-c++ ncurses ncurses-devel openssl openssl-devel libtool*
mkdir -p /data/dbdata
#查询是否存在mysql的用户组
if [ `grep "mysql" /etc/passwd | wc -l` -eq 0 ];then
echo "adding user mysql"
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
else
echo "mysql user is exist"
fi

wget
echo "tar xzvf mysql-5.1.63.tar.gz"
tar xzvf mysql-5.1.63.tar.gz
cd mysql-5.1.63
echo "configuring mysql,please wait-----------------"
./configure '--prefix=/usr/local/mysql' '--localstatedir=/data/dbdata/' '--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock' '--with-charset=utf8' '--with-extra-charsets=complex' '--with-pthread' '--enable-thread-safe-client' '--with-ssl' '--with-client-ldflags=-all-static' '--with-mysqld-ldflags=-all-static' '--with-plugins=partition,federated,innobase,csv,blackhole,myisam,innodb_plugin,heap,archive' '--enable-shared' '--enable-assembler'

if [ $? -ne 0 ];then
echo "configure filed ,please check it out!"
exit 1
fi

echo "make mysql, please wait for 20 minutes"
make
if [ $? -ne 0 ];then
echo "make filed ,please check it out!"
exit 1
fi

make install

chown -R mysql:mysql /usr/local/mysql
chown -R mysql.mysql /data/dbdata/

/usr/local/mysql/bin/mysql_install_db --user=mysql

cp ../my.cnf /etc/my.cnf

cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on

echo "mysql starting"
/etc/rc.d/init.d/mysqld start
if [ $? -ne 0 ];then
echo "mysql start filed ,please check it out!"
else
echo "mysql start successful,congratulations!"
fi

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值