MYSQL教程mysql自动化安装脚本(ubuntu and centos64)

前端之家收集整理的这篇文章主要介绍了MYSQL教程mysql自动化安装脚本(ubuntu and centos64)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

MysqL教程MysqL自动化安装脚本(ubuntu and centos64)》要点:
本文介绍了MysqL教程MysqL自动化安装脚本(ubuntu and centos64),希望对您有用。如果有疑问,可以联系我们。

Ubuntu MysqL自动化安装脚本
代码如下:

#/bin/bash
function hasDpkg
{
r=`dpkg -l | grep "$1"`
if [ -n "$r" ]
then
h=`dpkg -l | grep "ii $1"`
if [ -n "$h" ]
then
return 1
else
return 0
fi
else
return 0
fi
}

MysqL="MysqL-server-5.5"

hasDpkg $MysqL

r=$?

if [ $r -eq 1 ]
then
:
# echo "$MysqL was installed"
else
echo "$MysqL was not installed"
echo MysqL-server MysqL-server/root_password password adv | sudo debconf-set-selections
echo MysqL-server MysqL-server/root_password_again password adv | sudo debconf-set-selections //设定root 用户及其密码
apt-get install $MysqL
fi

CentOS64 MysqL 自动化安装脚本
代码如下:

#/bin/bash
function hasinstall
{
r=$(rpm -qa "$1")
if [ $r ]
then
return 1
else
return 0
fi
}

MysqL="MysqL-server"

hasinstall $MysqL

r=$?

if [ $r -eq 1 ]
then
:
echo "$MysqL was installed"
else
echo "$MysqL was not installed"
yum install MysqL MysqL-server MysqL-devel
service MysqLd start
fi
#add User to MysqL database
echo "INFORM:Enter database root password"
MysqL -uroot -p -hlocalhost </etc/cloud/MysqL/adduser.sql

adduser.sql 脚本
代码如下:

insert ignore into MysqL.user(Host,User,Password)
values('localhost','loadserver','adv');
flush privileges;

grant all privileges on *.* to loadserver@localhost identified by 'adv';

flush privileges;

猜你在找的MySQL相关文章