Install MySQL script in one click

Source: Internet
Author: User
Tags change settings dedicated server

Recently in the configuration of MySQL master-slave test, always repeat the installation of MySQL

So make a script, the MySQL process is to refer to someone else's

But the shell wrote it himself.


#!/bin/bash

#切换到下载目录

Cd/usr/local/src

#下载免免编译的包

wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz

#解压

Tar zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz

#移动解压的文件到安装目录

MV Mysql-5.6.29-linux-glibc2.5-x86_64/usr/local/mysql

#创建用户

Useradd-s/sbin/nologin MySQL

#切换到安装目录

Cd/usr/local/mysql

#创建mysql数据存储目录并将该目录设置为mysql的用和组

Mkdir-p/data/mysql; Chown-r Mysql.mysql/data/mysql

#执行初始化安装, define the user as the MySQL data store directory

./scripts/mysql_install_db--user=mysql--datadir=/data/mysql

#复制启动文件到init目录, and give execute permission

CP Support-files/mysql.server/etc/init.d/mysqld

chmod 755/etc/init.d/mysqld

#创建 the contents of the/ETC/MY.CNF quotation marks can be modified according to their own circumstances

echo "# for advice The change settings

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

# * * * Don't EDIT this FILE. It ' s a template which'll be copied to the

# * * * default location during install, and would be replaced if you

# * * * * Upgrade to a newer version of MySQL.


[Mysqld]


# Remove Leading # and set to the amount of RAM for the most important data

# Cache in MySQL. Start at 70% of all RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M


# Remove Leading # to turn on a very important data integrity option:logging

# Changes to the binary log between backups.

Log_bin=mysql-bin


# These is commonly set, remove the # and set as required.

Basedir =/usr/local/mysql

DataDir =/data/mysql

Port = 3306

server_id = 1

Socket =/data/mysql/mysql.sockt


# Remove Leading # To set options mainly useful for reporting servers.

# The server defaults is faster for transactions and fast selects.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M


Sql_mode=no_engine_substitution,strict_trans_tables

">/etc/my.cnf

#修改启动文件的程序安装目录和数据存储目录 (depending on the version this location may be different)

Sed-i ' 46c basedir=/usr/local/mysql '/etc/init.d/mysqld

Sed-i ' 47c datadir=/data/mysql '/etc/init.d/mysqld

#增加为服务, and set boot start

#启动mysql

Chkconfig--add mysqld

Chkconfig mysqld on

Service mysqld Start



Testing through the environment for centos6.4_64

This article is from the "Dessler" blog, make sure to keep this source http://312636.blog.51cto.com/302636/1772467

Install MySQL script in one click

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.