MySQL multi-instance installation

Source: Internet
Author: User

There are two methods

1. The installation port is 3306 mysql

Tar-zxvf mysql-5.1.44.tar.gz

Cd mysql-5.1.44

Create a mysql user group

Groupadd mysql

Create a user named mysql3306

Useradd-g mysql mysql3306

Compile and install

. /Configure -- prefix =/usr/local/mysql3306 -- with-unix-socket-path =/usr/local/mysql3306/var/mysql. sock -- sysconfdir =/usr/local/mysql3306/-- with-client-ldflags =-all-static -- with-mysqld-ldflags =-all-static -- disable-shared --- mysqld-user = mysql3306 -- with-extra-charsets = gb2312, big5, gbk

Make & make install

Create a configuration file directory and copy the configuration file

Mkdir/usr/local/mysql3306/etc

Cp support-files/my-medium.cnf/usr/local/mysql3306/etc/my. cnf

Add to system service and start up

Cp support-files/mysql. server/etc/init. d/mysqld3306

Chmod 755/etc/init. d/mysqld3306

Chkconfig -- add mysqld3306

Chkconfig -- level 2345 mysqld3306 on

Configure system environment variables

Echo "PATH =/usr/local/mysql3306/bin: \ $ PATH">/home/mysql3306/. bashrc

Initialize and install the database

/Usr/local/mysql3306/bin/mysql_install_db -- user = mysql3306

Chown-R mysql3306: mysql/usr/local/mysql3306 /*

Start the service

/Usr/local/mysql3306/bin/mysqld_safe -- user = mysql3306 &

Change the root password of a mysql database

/Usr/local/mysql3306/bin/mysqladmin-u root password root // change the password you need

Restart the mysql3306 Service

Service mysqld3306 restart

Ii. Install mysql on port 3307

Tar-zxvf mysql-5.1.44.tar.gz

Cd mysql-5.1.44

Create a mysql3307 user

Useradd-g mysql mysql3307

Compile and install

. /Configure -- prefix =/usr/local/mysql3307 -- with-unix-socket-path =/usr/local/mysql3307/var/mysql. sock -- sysconfdir =/usr/local/mysql3307/etc -- with-charset = utf8 -- without-debug -- with-client-ldflags =-all-static -- with-mysqld-ldflags = -all-static -- disable-shared -- with-mysqld-user = mysql3307 -- with-extra-charsets = gb2312, big5, gbk

Make & make install

Create a configuration file directory and copy the configuration file

Mkdir/usr/local/mysql3307/etc

Cp support-files/my-medium.cnf/usr/local/mysql3307/etc/my. cnf

Add to system service and start up

Cp support-files/mysql. server/etc/init. d/mysqld3307

Chmod 755/etc/init. d/mysqld3307

Chkconfig -- add mysqld3307

Chkconfig -- level 2345 mysqld3307 on

Initialize and install the database

/Usr/local/mysql3307/bin/mysql_install_db -- user = mysql3307

Chown-R mysql3307: mysql/usr/local/mysql3307 /*

Modify my. cnf to set the listening port to 3307.

Vi/usr/local/mysql3307/etc/my. cnf

Configure system environment variables

Echo "PATH =/usr/local/mysql3306/bin: \ $ PATH">/home/mysql3307/. bashrc

Start the mysql3307 Service

/Usr/local/mysql3307/bin/mysqld_safe -- user = mysql3307 &

Modify mysql3307 Database Password

/Usr/local/mysql3307/bin/mysqladmin-u root password root // change the password you need

Restart Database Service

Service mysqld3307 restart

Iii. Compile Parameter Parsing
-- Prefix =/usr/local/mysql3306 specify the installation path
-- With-unix-socket-path =/usr/local/mysql3306/var/mysql. sock specifies the socket file of the socket. It must be specified for multiple instances. Otherwise,/tmp/mysql is used by default for multiple instances. sock
-- Sysconfdir =/usr/local/mysql3306/etc mysql configuration file after the instance is started, [PREFIX/etc] In the installation path by default. The purpose is to emphasize the need to configure my for each instance. cnf and/etc/my. cnf does not exist because the startup script usually reads/etc/my first. cnf
-- With-charset = utf8 default Character Set
-- With-extra-charsets = gb2312, big5, and gbk support other character sets to reduce unnecessary overhead. Mysql supports more than 20 character sets by default.
-- Without-debug removes the debugging mode, which is said to be optimized.
-- Enable-aggreger uses the assembly version of some character functions, which is said to optimize the performance.
-- With-client-ldflags =-all-static compile the client in pure static mode. If the client is not required on the server instance, do not use this option. However, we recommend that you keep it and log on to the database server, mysql is a default habit.
-- With-mysqld-ldflags =-all-static compile the server in pure static mode. It is said to be useful for performance optimization.
-- Disable-shared does not provide dynamic link libraries
-- With-mysqld-user = mysql startup user set to mysql

  • 1
  • 2
  • Next Page

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.