MySQL install script under the OS of Ubuntu

Source: Internet
Author: User

#!/bin/bash
echo "-----------------------start install MySQL----------------------"
Apt-get install make CMake Libncurses5-dev bison g++
Mkdir-p/data/mysql/dbdata
If [' grep ' mysql '/etc/passwd | wc-l '-eq 0];then
echo "adding user MySQL"
Groupadd MySQL
useradd-g MySQL mysql-s/bin/false
Else
echo "MySQL user is exist"
Fi

wget http://downloads.mysql.com/archives/MySQL-5.6/mysql-5.6.23.tar.gz
echo "Tar xzvf mysql-5.6.23.tar.gz"
Tar xzvf mysql-5.6.23.tar.gz
CD mysql-5.6.23
echo "CMake mysql,please wait-----------------"
CMake '-dcmake_install_prefix=/usr/local/mysql '-dsysconfdir=/etc '-dmysql_unix_addr=/usr/local/mysql/ Mysql.sock '-ddefault_charset=utf8 '-ddefault_collation=utf8_general_ci '-dextra_charsets=all '-DWITH_MYISAM_ Storage_engine=1 '-dwith_innobase_storage_engine=1 '-dwith_memory_storage_engine=1 '-DWITH_READLINE=1 '- Denabled_local_infile=1 '-dmysql_datadir=/data/mysql/dbdata '-dmysql_user=mysql '-DWITH_DEBUG=0 '

If [$?-ne 0];then
echo "Configure failed, please check it out!"
Exit 1
Fi

echo "Make MySQL, minutes"
Make && make install
If [$?-ne 0];then
echo "Make failed, check it out!"
Exit 1
Fi

Make install

Chown-r Mysql:mysql/usr/local/mysql
Chown-r mysql.mysql/data/mysql/dbdata/

CP./SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF
CP./support-files/mysql.server/etc/init.d/mysqld
chmod 755/etc/init.d/mysqld

Ln–s/usr/local/mysql/bin/mysql/usr/bin
Ln–s/usr/local/mysql/bin/mysqladmin/usr/bin

echo "Init mysql,please wait-----------------"

/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data-- Skip-name-resolve--user=mysql

If [$?-ne 0];then
echo "Inti failed, please check it out!"
Exit 1
Fi

echo "MySQL starting"
/etc/init.d/mysqld start
If [$?-ne 0];then
echo "MySQL start filed, please check it out!"
Else
echo "MySQL start successful,congratulations!"
Fi

MySQL install script under the OS of Ubuntu

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.