共计 1847 个字符,预计需要花费 5 分钟才能阅读完成。
这篇文章主要为大家展示了“mysql 脚本安装的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让丸趣 TV 小编带领大家一起研究并学习一下“mysql 脚本安装的示例分析”这篇文章吧。
脚本安装
#!/bin/bash
echo ———————–start install mysql———————-
# 安装必要的包
yum -y install gcc gcc-c++ ncurses openssl openssl-devel make kernel-devel m4 ncurses-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
# 下载 mysql5.1tar 包
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.63.tar.gz
echo tar xzvf mysql-5.1.63.tar.gz
# 解压 tar 包
tar xzvf mysql-5.1.63.tar.gz
# 进入安装目录进行安装
cd mysql-5.1.63
echo configuring mysql,please wait—————–
# 进行编译配置 prefix 为软件安装目录,localstatedir 为数据存放目录等
./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
cp /usr/local/mysql/bin/mysql* /usr/bin/
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
以上是“mysql 脚本安装的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注丸趣 TV 行业资讯频道!