


#!/bin/bash
# mysql数据库安装,提供mysql5.5和mysql5.6
# by sun
# 安装支持
yum -y install perl perl-devel
# 创建mysql数据库运行用户
useradd mysql -s /sbin/nologin -M
# 下载mysql数据库程序包
wget http://west.724001.com/abc/linuxweb/mysql/mysql-5.6.35-linux-x86_64.tar.gz
# 解压下载的数据库程序包
tar -zxvf mysql-5.6.35-linux-x86_64.tar.gz
# 将解压后的程序移动到指定目录使用
mkdir -p /application/
mv mysql-5.6.35-linux-glibc2.5-x86_64 /application/mysql-5.6.35
# 安装生成mysql数据库初始数据
/application/mysql-5.6.35/scripts/mysql_install_db --basedir=/application/mysql-5.6.35 --datadir=/application/mysql-5.6.35/data
#tree /application/mysql-5.6.35/data
# 复制mysql数据库配置文件到/etc/my.cnf
/bin/cp /application/mysql-5.6.35/support-files/my-default.cnf /etc/my.cnf
# 复制mysql数据库启动文件到/etc/init.d/目录
/bin/cp /application/mysql-5.6.35/support-files/mysql.server /etc/init.d/mysqld
# 修改mysql数据库启动文件中的路径信息
sed -i "s#/usr/local/mysql#/application/mysql-5.6.35#g" /etc/init.d/mysqld
sed -i "s#/usr/local/mysql#/application/mysql-5.6.35#g" /application/mysql-5.6.35/bin/mysqld_safe #(mysql5.6使用)
# 设置mysql数据库目录所有者权限
chown mysql.mysql /application/mysql-5.6.35/ -R
service mysqld start
service mysqld restart
service mysqld stop
export PATH=/home/mysql56/bin:$PATH #设置环境变量
source /etc/profile



文章评论 本文章有个评论