MySQL multi-instance installation under CentOS 3306, 3307 instances (2014-10-15)

Source: Internet
Author: User
Tags log log mysql create mysql view

Background Notes
There are several ways to install MySQL, such as binary installation, source code compilation and installation, Yum installation, and so on. Yum installation can only install MySQL version 5.1, the source code installation and compilation process is relatively long, if the source code is not modified and requires the use of a higher version of MySQL, we recommend the use of a binary installation. This article installs MySQL in binary and uses Mysqld_mutil for MySQL multi-instance management.
is MySQL installed?
first check if MySQL is installed on the server, and if the port is occupied, you need to select a different port.
Download MySQL 
Cd/usr/srcwget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
Decompression and Migration
TAR-ZXVF  mysql-5.6.21-linux-glibc2.5-x86_64.tar.gzmv mysql-5.6.21-linux-glibc2.5-x86_64  /usr/local/ Mysql
shutting down the firewall
Temporary shutdown: Service iptables stop permanently closed: chkconfig iptables off
Turn off SELinux
Vim/etc/sysconfig/selinux changes selinux to DISABLED, which is selinux=disabled
initializing user groups and users
Create a MySQL user group and user, and this user is a non-logged on create user group: Groupadd mysql Create non-logged on User: Useradd-g mysql-s/sbin/nologin-d/opt/mysql MySQL View user information after creation: ID msyql# ID mysqluid=500 (mysql) gid=500 (MySQL) groups=500 (MySQL)
create a related directory
Change Directory Permissions
Chown-r Mysql:mysql/data/mysql/chown-r mysql:mysql/usr/local/mysql/
Adding environment Variables
Echo ' Export path= $PATH:/usr/local/mysql/bin ' >>  

copy my.cnf file to etc directory
CD/USR/LOCAL/MYSQL/SUPPORT-FILESCP my-default.cnf/etc/my.cnf

Modify MY.CNFReplace all of the following with the contents of/ETC/MY.CNF:
[Client] port=3306 Socket=/tmp/mysql.sock [mysqld_multi] mysqld =/usr/local/mysql/bin/mysqld_safe mysqladmin =/usr/ Local/mysql/bin/mysqladmin log =/data/mysql/mysqld_multi.log [mysqld] user=mysql basedir =/usr/local/mysql sql_mode= No_engine_substitution,strict_trans_tables [mysqld3306] mysqld=mysqld mysqladmin=mysqladmin datadir=/data/mysql/ Mysql_3306/data port=3306 server_id=3306 socket=/tmp/mysql_3306.sock log-output=file slow_query_log = 1 Long_query_ Time = 1 Slow_query_log_file =/data/mysql/mysql_3306/log/slow.log Log-error =/data/mysql/mysql_3306/log/error.log Binlog_format = Mixed Log-bin =/data/mysql/mysql_3306/log/mysql3306_bin [mysqld3307] Mysqld=mysqld mysqladmin= Mysqladmin datadir=/data/mysql/mysql_3307/data port=3307 server_id=3307 socket=/tmp/mysql_3307.sock log-output=file Slow_query_log = 1 Long_query_time = 1 Slow_query_log_file =/data/mysql/mysql_3307/log/slow.log Log-error =/data/mysql/ Mysql_3307/log/error.log Binlog_format = Mixed Log-bin =/data/mysql/mYsql_3307/log/mysql3307_bin 
Initialize database
Descriptioninstallation directory for--basedir:mysql--datadir: Data file directory for database--defaults-file:mysql configuration file directory
need to see two OK, only to demonstrate success, such as:
To see if the database was initialized successfullyCd/data/mysql/mysql_3306/data set Startup file
Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql
mysqld_multi for multi-instance management
Start all instances:/usr/local/mysql/bin/mysqld_multi Start View All instance states:/usr/local/mysql/bin/mysqld_multi report launches a single instance:/usr/local /mysql/bin/mysqld_multi start 3306 Stop Single instance:/usr/local/mysql/bin/mysqld_multi Stop 3306 View Single instance status:/usr/local/mysql/bin/ Mysqld_multi Report 3306
change password
Because MySQL root user initial password is empty, so need to log in to MySQL to change password, the following 3306 for example: Mysql-s/tmp/mysql_3306.sock  Set password for [email protected ] ' localhost ' =password (' 123456 '); flush privileges;
New user and authorization
In general, new databases require a new user to connect to the program, which requires only insert, UPDATE, delete, select permissions. Add a user and authorize the following: Grant Select,delete,update,insert on * * to [email protected] ' 192.168.1.% ' identified by ' 123456 '; flush privileges;


MySQL multi-instance installation under CentOS 3306, 3307 instances (2014-10-15)

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.