Ubuntu MySQL Automation installation script
Copy Code code as follows:
#/bin/bash
function hasdpkg
{
R= ' Dpkg-l | grep "$"
If [-N "$r"]
Then
H= ' Dpkg-l | grep "II" '
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 is 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//Set root user and password
Apt-get Install $mysql
Fi
CentOS64 MySQL Automation installation script
Copy Code code as follows:
#/bin/bash
function Hasinstall
{
r=$ (Rpm-qa "$")
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 is 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 Script
Copy Code code as follows:
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;