Linux same system installs two MySQL

Source: Internet
Author: User
Tags mysql version mysql login

MYSQL version: MYSQL-5.5.37

Operating system: Ubuntu 12.04.5 LTS \ \l

Installation steps:

    1. 第一个MYSQL安装路径/usr/local/mysql 监听3306端口启动文件/etc/init.d/mysql
    2. 第二个MYSQL安装路径/data/mysql 监听3307端口启动文件/etc/init.d/mysql2

1 , install the first MySQL in/usr/local/mysql

Setup 1: #wget  http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz#tar -zxvf  cmake-2.8.12.2.tar.gz#cd cmake-2.8.12.2#./bootstrap#./configure#make && make  install  system If it is CentOS, just install another component #wget http://invisible-island.net/datafiles/release/ncurses.tar.gz#./ CONFIGURE#MAKE && MAKE INSTALLSETUP 2: Installing mysql 5.5.37#wget http:// cdn.mysql.com/downloads/mysql-5.5/mysql-5.5.37.tar.gztar -zxvf mysql-5.5.37.tar.gz#cd  Mysql-5.5.37#cmake -dcmake_install_prefix=/usr/local/mysql -dextra_charsets=all -denabled_local _infile=1 -dwith_readline=1 -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci - dwith_embedded_server=1 -dwith_ssl=system  #make  && make install  After a long wait, I finally finished the   #groupadd  mysql#useradd -g mysql mysql#cp /usr/local/mysql/ support-files/my-medium.cnf /etc/my.cnf  #vim  /etc/my.cnf  #需要加入basedir, and DataDir will go wrong [mysqld]basedir =/usr/local/mysqldatadir =/usr/local/mysql/ Data  #/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data &  #chown  -r mysql /usr/local/mysql/data# chgrp -r mysql /usr/local/mysql/. #cp  /usr/local/mysql/support-files/mysql.server /etc /init.d/mysql#chmod 755 /etc/init.d/mysql#chkconfig --level 345 mysql on#echo   "/usr/local/mysql/lib/mysql"  >> /etc/ld.so.conf#echo  "/usr/local/lib"  >> /etc/ld.so.conf#ldconfig #/etc/init.d/mysql start #/usr/local/mysql/bin/mysqladmin -u  root password broadengate empire cms,phome.net #/etc/init.d/mysql restart# /etc/init.d/mysql stopok finally finished ~

Strong style= "font-family: ' Microsoft Ya Black ', Tahoma;line-height:25.6000003814697px;white-space:normal;background-color:rgb ( 255,255,255); " >2, install the second: (Basic and first, note the path and permissions)

#tar  -zxvf mysql-5.5.37.tar.gz#cd mysql-5.5.37#cmake -dcmake_install_prefix=/data/mysql  -dmysql_datadir=/data/mysql/data -dextra_charsets=all -ddefault_charset=utf8 -ddefault_ collation=utf8_general_ci -dwith_innobase_storage_engine=1 -dwith_archive_storage_engine=1 - Dwith_blackhole_storage_engine=1 -dwith_federated_storage_engine=1 -dwith_partition_storage_engine=1  -dwith_perfschema_storage_engine=1 -dmysql_unix_addr=/data/mysql/mysqld.sock -dmysql_tcp_port= 3307 -dwith_debug=0 -denabled_local_infile=1 -dwith_readline=1 -dwith_ssl=system - dwith_zlib=system -dwith_embedded_server=1#make && make install#cp /data/ mysql/support-files/my-medium.cnf /data/mysql/my.cnf   #vim  /data/mysql/my.cnf # Need to join Basedir, and DataDir otherwise will be a problem [mysqld]basedir =/data/mysqldatadir =/data/mysql/data     #/data/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data &  # chown -r mysql /data/mysql/data#chgrp -r mysql /data/mysql/. #cp  /usr/local/ Mysql/support-files/mysql.server /etc/init.d/mysql2#chmod 755 /etc/init.d/mysql2

Span style= "font-family: ' Microsoft Jas Black ', Tahoma;line-height:25.6000003814697px;background-color:rgb (255,255,255);" > > Okay, here's the point.

 #vi  /etc/init.d/mysql2 1) find the following file to add basedir=/data/mysqldatadir= /DATA/MYSQL/DATA CONF=/DATA/MYSQL/MY.CNF 2) Modify the following parameters   the $bindir/mysqld_safe --datadir= $datadir  --pid-file= $server _pid_file  $other _args >/dev/null 2>&1& replaced by:  $bindir/ mysqld_safe --defaults-file=/data/mysql/my.cnf --datadir= $datadir  --pid-file= $server _pid_file   $other _args >/dev/null 2>&1 & 3) Comment out the following sentence (add a # above):  parse_server_ arguments  ' $print _defaults  $extra _args mysqld server mysql_server mysql.server '     4). Save exit and Add service:  CHKCONFIG --ADD /ETC/INIT.D/MYSQL2 

Start two MySQL separately

#/etc/init.d/mysql Start #/ETC/INIT.D/MYSQL2 start

View the next process

[email protected]:/usr/local/mysql$ ps -ef|grep mysqlroot      23328     1  0 apr17 ?         00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data -- Pid-file=/usr/local/mysql/data/ubuntu.pidmysql    23616 23328  0 apr17  ?        00:00:54 /usr/local/mysql/bin/mysqld -- Basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin  --user=mysql --log-error=/usr/local/mysql/data/ubuntu.err --pid-file=/usr/local/mysql/data/ ubuntu.pid --socket=/tmp/mysql.sock --port=3306root     23777      1  0 apr17 ?        00:00:00  /bin/sh mysql/bin/mysqld_safe --defaults-file=/data/my.cnf --user=mysqlmysql    24915 23777   0 apr18 ?        00:00:38 /data/mysql/bin/ mysqld --defaults-file=/data/my.cnf --basedir=/data/mysql --datadir=/data/mysql/data -- plugin-dir=/data/mysql/lib/plugin --user=mysql --log-error=/data/mysql/data/ubuntu.err -- Pid-file=/data/mysql/data/ubuntu.pid --socket=/data/mysql/mysqld.

Viewing ports

[email protected]:/usr/local/mysql$ netstat -nalp|grep  ' 3306 ' (No info could  be read for  "-P":  geteuid () =1000 but you should be root.) tcp        0      0 0.0.0.0:3306             0.0.0.0:*                listen      -               tcp         0      0 192.168.1.119:3306       192.168.1.150:41410     ESTABLISHED -               [email protected]:/usr/local/mysql$  netstat -nalp|grep  ' 3307 ' (no info could be read for  "-P":  geteuid () =1000 but you  Should be root.) tcp        0      0 0.0.0.0:3307             0.0.0.0:*                listen

You can see that two MySQL runs normally

Landing

The difference is that we have to add sock to the second MySQL login, otherwise the default is the first database

Mysql-uroot-p--socket=/data/mysql/mysql.sock


This article is from the "xiangcun168" blog, make sure to keep this source http://xiangcun168.blog.51cto.com/4788340/1663165

Linux same system installs two MySQL

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.