Chinaunix首页 | 论坛 | 博客
  • 博客访问: 478756
  • 博文数量: 53
  • 博客积分: 492
  • 博客等级: 下士
  • 技术积分: 866
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-14 15:12
文章分类

全部博文(53)

文章存档

2016年(1)

2015年(3)

2014年(17)

2013年(9)

2012年(7)

2011年(16)

我的朋友

分类: Mysql/postgreSQL

2016-03-24 10:14:07

#!/bin/bash
user=mysql
group=mysql
#create group if not exists
egrep "^$group" /etc/group >& /dev/null
if [ $? -ne 0 ]
then
groupadd $group
fi
#create user if not exists
egrep "^$user" /etc/passwd >& /dev/null
if [ $? -ne 0 ]
then
useradd -g $group $user
fi
cur_dir=$(cd "$(dirname "$0")"; pwd)
data_dir=/htdata/mysql
src_dir=/usr/local/src
bin_dir=/usr/local/mysql
yum install git wget
yum install -y gcc gcc-c++ make
yum install –y openssl openssl-devel ncurses ncurses-devel cmake
cd $src_dir
if [ ! -f $src_dir/mysql-5.5.41.tar.gz ] ; then
wget
fi
if [ ! -d $src_dir/mysql-5.5.41 ] ; then
tar -zxvf mysql-5.5.41.tar.gz
fi
if [ ! -e $bin_dir/bin/mysqld_safe ] ; then
cd $src_dir/mysql-5.5.41
cmake . -DCMAKE_INSTALL_PREFIX=$bin_dir -DMYSQL_DATADIR=$data_dir
make && make install
fi
if [ ! -e $bin_dir/bin/mysqld_safe ] ; then
echo "fail to install mysql"
exit;
fi
cd $data_dir
chown -R mysql $data_dir
chgrp -R mysql .
cp $cur_dir/init_sh/mysqld /etc/init.d/
cp $cur_dir/sys_config/my.cnf /etc/
chown root.root /etc/rc.d/init.d/mysqld
cd /usr/local/mysql
chown -R root .
scripts/mysql_install_db --user=mysql
$bin_dir/bin/mysqld_safe --user=mysql
$bin_dir/bin/mysqladmin -u root password '123456'
chkconfig --add mysqld
chkconfig --level 3 mysqld on
chkconfig --level 5 mysqld on
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
mysql -u root -p -e "SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');"
阅读(1444) | 评论(0) | 转发(0) |
0

上一篇:不让Vim自动生成~备份文件

下一篇:没有了

给主人留下些什么吧!~~