Compile and install the MySQL 5.6 script in the source code package

Source: Internet
Author: User

The MySQL5.6 script is compiled and installed in the source code package. Two MySQL databases are installed on one machine. The port, installation path, and socket file location are specified during compilation.

The installed MySQL installation file can be packaged and copied to other machines for use. You only need to initialize it when using other machines, and grant related directory permissions.

Install MySQL with port 3306:


#! /Bin/bash
Groupadd mysql
Useradd-g mysql-s/sbin/nologin
Mkdir/data/3306.
Chown-R mysql. mysql/data/3306
Chmod 755/data/3306
# Mount-o loop/tmp/turbolinux12.iso/mnt/
Yum-y install make gcc-c ++ cmake bison-devel ncurses-devel openssl-devel bison
Tar Z/tmp/mysql-5.6.16.tar.gz-C/usr/local/src/
Mv/usr/local/src/mysql-5.6.16 // usr/local/src/mysql-master
# Read-n1 var press any key to continue
Read-n1 var
Cd/usr/local/src/mysql-master
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-master /\
-DMYSQL_DATADIR =/data/3306/data \
-DMYSQL_TCP_PORT = 3306 \
-DMYSQL_UNIX_ADDR =/var/run/mysqld/mysql-master.sock \
-DSYSCONFDIR =/usr/local/mysql-master \
-DDEFAULT_CHARSET = gbk \
-DDEFAULT_COLLATION = gbk_chinese_ci \
-DWITH_EXTRA_CHARSETS = ALL \
-DMYSQL_USER = mysql
Read-n1 var
Make
Read-n1 var
Make install
Read-n1 var
Chown-R mysql. mysql/usr/local/mysql-master
/Usr/local/mysql-master/scripts/mysql_install_db -- basedir =/usr/local/mysql-master -- datadir =/data/3306/data -- user = mysql
Cp/usr/local/mysql-master/support-files/mysql. server/etc/init. d/mysqld-master
Read-n1 var
Chmod + x/etc/init. d/mysqld-master
Chkconfig -- add mysqld-master
Chkconfig mysqld-master on
/Etc/init. d/mysqld-master start

Install mysql with port 3307:

#! /Bin/bash
Groupadd mysql
Useradd-g mysql-s/sbin/nologin
Mkdir/data/3307.
Chown-R mysql. mysql/data/3307
Chmod 755/data/3307
# Mount-o loop/tmp/turbolinux12.iso/mnt/
Yum-y install make gcc-c ++ cmake bison-devel ncurses-devel openssl-devel bison
Tar Z/tmp/mysql-5.6.16.tar.gz-C/usr/local/src/
Mv/usr/local/src/mysql-5.6.16 // usr/local/src/mysql-slave
Read-n1 var
Cd/usr/local/src/mysql-slave
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-slave /\
-DMYSQL_DATADIR =/data/3307/data \
-DMYSQL_TCP_PORT = 3307 \
-DMYSQL_UNIX_ADDR =/var/run/mysqld/mysql-slave.sock \
-DSYSCONFDIR =/usr/local/mysql-slave \
-DDEFAULT_CHARSET = gbk \
-DDEFAULT_COLLATION = gbk_chinese_ci \
-DWITH_EXTRA_CHARSETS = ALL \
-DMYSQL_USER = mysql
Read-n1 var
Make
Read-n1 var
Make install
Read-n1 var
Chown-R mysql. mysql/usr/local/mysql-slave
/Usr/local/mysql-slave/scripts/mysql_install_db -- basedir =/usr/local/mysql-slave -- datadir =/data/3307/data -- user = mysql
Cp/usr/local/mysql-slave/support-files/mysql. server/etc/init. d/mysqld-slave
Read-n1 var
Chmod + x/etc/init. d/mysqld-slave
Chkconfig -- add mysqld-slave
Chkconfig mysqld-slave on
/Etc/init. d/mysqld-slave start

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

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.