Mysql Automation Installation Script (Ubuntu and CENTOS64) _mysql

Source: Internet
Author: User
Tags flush
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;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.