MySQL source code compilation and installation (5.5 and 5.6 coexist)

Source: Internet
Author: User

MySQL source code compilation and installation (5.5 and 5.6 coexist)

Introduction:

How to run two or more MySQL services simultaneously on one server.

1. MySQL 5.6

Shell> useradd-r-s/sbin/nologin mysql

Shell> wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz

Shell> tar zxf mysql-5.6.27.tar.gz
Shell> cd mysql-5.6.27
Shell> cmake.; make install

Shell> chown-R root: mysql/usr/local/mysql
Shell> chown-R mysql/usr/local/mysql/data

Shell> cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf
Shell> cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysqld

Shell>/usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql/-- datadir =/usr/local/mysql/data/

Shell> service mysqld start

Shell> echo "PATH = $ PATH:/usr/local/mysql/bin/">/etc/profile
Shell> source/etc/profile

Shell> mysql-e 'select version (); '# MySQL 5.6 is successfully installed.
+ ----------- +
| Version () |
+ ----------- +
| 5.6.27 |
+ ----------- +

 

2. MySQL 5.5

 

Shell> wget ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.5/mysql-5.5.46.tar.gz

Shell> tar zxf mysql-5.5.46.tar.gz
Shell> cd mysql-5.5.46
Shell> cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql5 # specify the installation path
Shell> make; make install

Shell> chown-R root: mysql/usr/local/mysql5
Shell> chown-R mysql/usr/local/mysql5/data

Shell> cp/usr/local/mysql5/support-files/my-medium.cnf/etc/my5.cnf
Shell> cp/usr/local/mysql5/support-files/mysql. server/etc/init. d/mysqld5

Shell>/usr/local/mysql5/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql5/-- datadir =/usr/local/mysql5/data/

Shell> vim/etc/my5.cnf # modify the port and socket

Port = 3307
Socket =/tmp/mysql5.sock

Shell>/usr/local/mysql5/bin/mysqld_safe -- defaults-file =/etc/my5.cnf & # specify the configuration file path and start the database

Shell> mysql-uroot-S/tmp/mysql5.sock-e 'select version (); '# MySQL 5.5 is successfully installed.
+ ------------ +
| Version () |
+ ------------ +
| 5.5.46-log |
+ ------------ +

Shell> mysql-uroot-h127.0.0.1-P3307-e 'select version (); '# or by specifying IP: PORT
+ ------------ +
| Version () |
+ ------------ +
| 5.5.46-log |
+ ------------ +

 

3. Write the Startup Script

 

Shell> vim/etc/init. d/mysqld5 # specify the configuration file path for the startup parameter (-- defaults-file =/etc/my5.cnf)

'Start ')
# Start daemon

# Safeguard (relative paths, core dumps ..)
Cd $ basedir

Echo $ echo_n "Starting MySQL"
If test-x $ bindir/mysqld_safe
Then
# Give extra arguments to mysqld with the my. cnf file. This script
# May be overwritten at next upgrade.
$ Bindir/mysqld_safe -- defaults-file =/etc/my5.cnf -- datadir = "$ datadir" -- pid-file = "$ mysqld_pid_file_path" $ other_args>/dev/null 2> & 1 &
Wait_for_pid created "$! "" $ Mysqld_pid_file_path "; return_value = $?

# Make lock for RedHat/SUSE
If test-w "$ lockdir"
Then
Touch "$ lock_file_path"
Fi

Exit $ return_value
Else
Log_failure_msg "Couldn't find MySQL server ($ bindir/mysqld_safe )"
Fi
;;

Shell> service mysqld5 stop # OK. You can also use scripts to manage MySQL 5.5!

Install MySQL 5.7.9 through source code compilation

CentOS 7 source code compilation and installation of PHP5.6, Nginx1.7.9 and MySQL (establish LNMP environment)

MySQL 5.7.9 source code compilation and installation instructions

Compile and install MySQL 5.7.5 from the source code in CentOS 6.6

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

Install MySQL 5.6 with the source code in CentOS 7

This article permanently updates the link address:

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.