MySQL automatic installation script (Ubuntu and CentOS64)

Source: Internet
Author: User
Automated tumysql installation script #/bin/bashfunctionhasDpkg {r = 'dpkg-l | grep "$1" 'if [-n "$ r"] then & nb

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
 

CentOS 64 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;

MySQL authoritative guide (original book version 2nd) Clear Chinese scanning version PDF http://www.linuxidc.com/Linux/2014-03/98821.htm

Install MySQL 5.6 script http://www.linuxidc.com/Linux/2014-04/99991.htm

MySQL source installation http://www.linuxidc.com/Linux/2014-04/100758.htm

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

For more information about CentOS, see the CentOS topic page http://www.linuxidc.com/topicnews.aspx? Tid = 14

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-05/101452.htm

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.