Mysql automated installation script (ubuntuandcentos64) _ MySQL

Source: Internet
Author: User
Mysql automated installation script (ubuntuandcentos64) CentOS6CentOSUbuntu

Ubuntu Mysql automated installation script

#/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/root_password password adv | sudo debconf-set-selections
Echo mysql-server/root_password_again password adv | sudo debconf-set-selections // set the root user and its password
Apt-get install $ mysql
Fi

CentOS64 mysql automated installation script

#/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-server mysql-devel
Service mysqld start
Fi
# Add User to Mysql database
Echo "INFORM: Enter database root password"
Mysql-uroot-p-hlocalhost
Adduser. SQL script

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;

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.