centos6.5 installing mysql5.6 Single Instance and multiple instances (single profile)

Source: Internet
Author: User
Tags chmod gettext openssl

installation MySQL

Create a mysql user

Useradd MySQL// There is no need to create

Uninstall the original mysql rpm package

Rpm-qa|grep mysql// query whether there is a related package

Yum-y Remove *mysql*// I'm using yum to unload it.

Turn off the firewall and turn off selinux

Service iptables stop// personal habitual shutdown firewall

Sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config

Setenforce 0

Install the required dependency packages

Yum-y install make GCC gcc-c++ Gcc-gfortran Flex Bison file Libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-de Vel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel Glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2fsprogs-dev El krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel un Zip Libcap lsof

installation CMake

requires cmake to configure compilation after Mysql5.6 version

TAR-ZXVF cmake-2.8.5.tar.gz

CD cmake-2.8.5

./configure

Gmake && gmake Install

Start Installation MySQL

TAR-ZXVF mysql-5.6.4-m7.tar.gz

CD MYSQL-5.6.4-M7

CMake \

-dcmake_install_prefix=/usr/local/mysql \

-dmysql_datadir=/usr/local/mysql/data \

-DSYSCONFDIR=/ETC \

-dmysql_user=mysql \

-dwith_myisam_storage_engine=1 \

-dwith_innobase_storage_engine=1 \

-dwith_memory_storage_engine=1 \

-dwith_readline=1 \

-dmysql_unix_addr=/var/lib/mysql/mysql.sock \

-dmysql_tcp_port=3306 \

-denabled_local_infile=1 \

-dwith_partition_storage_engine=1 \

-dextra_charsets=all \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-dwith_debug=0 \

-dwith_ssl=system

Make && make install

============================================******************************************========================= ===================================

Single-Instance the installation Operation

After installing the relevant actions

Modify mysql install directory permissions

chmod +W/USR/LOCAL/MSYQL

Chown-r Mysql.mysql/usr/local/mysql

//in the StartMySQLservice, search in a certain ordermy.cnf, first in/ etcdirectory, it will search for "$basedir/my.cnf"is the installation directory/usr/local/mysql/my.cnf, this is the newMySQLThe default location for the configuration file! Note: inCentOS 6.xversion of the operating system, after the minimum installation is complete,/ etcdirectory, there will be amy.cnf, you need to rename this file to a different name. such as:/etc/my.cnf.bak, otherwise the file will interfere with the source installationMySQLthe correct configuration, causing the failure to start. Since we have uninstalled the minimum installation after the completion of themysqLibrary So, there is no need to operate.

CD support-files/

If you have my.cnf , back up .

Mv/etc/my.cnf/etc/my.cnf.bak

Copy the configuration file to etc

CP MY-MEDIUM.CNF/ETC/MY.CNF

Execute the initialization configuration script, create the system's own database and table, note the path of the configuration file

/usr/local/mysql/scripts/mysql_install_db–defaults-file=/etc/my.cnf–basedir=/usr/local/mysql–datadir=/usr/ Local/mysql/data–user=mysql

Copy the mysql installation directory under the support-files Service script to the init.d directory

# Copy Script

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

# give permission

chmod +x/etc/init.d/mysqld

# set boot up

Chkconfig mysqld on

# start MySQL

Service mysqld start or /etc/init.d/mysql start

mysql5.6.x After successful startup,root does not have a password, we need to set the root password. Before setting, we need to set PATH, or we can't call MySQL directly.

Modify the /etc/profile file

Vim/etc/profile

Add at the end of the file

Path=/usr/local/mysql/bin: $PATH

# Let the configuration take effect immediately

Source/etc/profile

# Login test, default is no password , Direct return to enter

Mysql-uroot-p

Set mysqlroot user Password

mysqladmin-u root Password "Newpass"

# if root has already set a password, use the following method

Mysqladmin-uroot-ppassword password "Newpass"

# Verify the mysql installation path

ls-ld/usr/local/mysql/

============================================******************************************========================= ===================================

Multiple instances of the installation Operation

Then the above source package installation is complete.

1. Create a multi-instance database folder

mkdir-pv/usr/local/mysql/data/{3306,3307,3308}

Chown-r mysql.mysql/usr/local/mysql/data/

2, initializing the database

Cd/usr/local/mysql

scripts/mysql_install_db–user=mysql–basedir=/usr/local/mysql–datadir=/usr/local/mysql/data/3306/

scripts/mysql_install_db–user=mysql–basedir=/usr/local/mysql–datadir=/usr/local/mysql/data/3307/

scripts/mysql_install_db–user=mysql–basedir=/usr/local/mysql–datadir=/usr/local/mysql/data/3308/

3. Prepare config file # to provide multiple profile templates

CD bin

./mysqld_multi–example >/usr/local/mysql/data/multi.cnf

4. Modify the template file (without commenting out)

Vim/usr/local/mysql/data/multi.cnf

[MYSQLD_MULTI]CD

Mysqld =/usr/local/mysql/bin/mysqld_safe

Mysqladmin =/usr/local/mysql/bin/mysqladmin

user = root

#password = root #设置了密码后一定要开启, or there will be a problem with the command stop (three instance database password)

[Mysqld1]

Socket =/tmp/mysql.sock1

Port = 3306

Pid-file =/usr/local/mysql/data/3306/mysql.pid

DataDir =/usr/local/mysql/data/3306/

[Mysqld2]

Socket =/tmp/mysql.sock2

Port = 3307

Pid-file =/usr/local/mysql/data/3307/mysql.pid

DataDir =/usr/local/mysql/data/3307/

#language =/usr/local/mysql/share/mysql/english

#user = Unix_user1

[MYSQLD3]

#mysqld =/path/to/mysqld_safe

#ledir =/path/to/mysqld-binary/

#mysqladmin =/path/to/mysqladmin

Socket =/tmp/mysql.sock3

Port = 3308

Pid-file =/usr/local/mysql/data/3308/mysql.pid

DataDir =/usr/local/mysql/data/3308/

#language =/usr/local/mysql/share/mysql/swedish

#user = Unix_user2

5. Modify the/etc/profile file

Vim/etc/profile

Add at the end of the file

Path=/usr/local/mysql/bin: $PATH

#让配置立即生效

Source/etc/profile

6. Start the MSYQL database

MYSQLD_MULTI–DEFAULTS-FILE=/USR/LOCAL/MYSQL/DATA/MULTI.CNF start

View port Status

NETSTAT-ANPT |grep mysqld

TCP 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 25470/mysqld

TCP 0 0 0.0.0.0:3308 0.0.0.0:* LISTEN 25476/mysqld

TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 25453/mysqld

7. Set MySQL password

Mysqladmin-uroot-s/tmp/mysql.sock1 Password "root"

Mysqladmin-uroot-s/tmp/mysql.sock2 Password "root"

Mysqladmin-uroot-s/tmp/mysql.sock3 Password "root"

8, enter the database

Mysql-s/tmp/mysql.sock1-proot

9, close the database 3 ways.

Mysqladmin-s/tmp/mysql.sock1 Shutdown-proot

Mysqld_multi–defaults-file=/usr/local/mysql/data/multi.cnf stop


This article is from the "Jinchuang" blog, make sure to keep this source http://jinchuang.blog.51cto.com/8690689/1844381

centos6.5 installing mysql5.6 Single Instance and multiple instances (single profile)

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.