How to install two Mysql on one machine
This article shows you how to install two Mysql on a machine, the content is concise and easy to understand, absolutely can make you shine, through the detailed introduction of this article I hope you can gain something.
Most documents on the web use mysql_multi to implement multiple mysql instances running on a machine. But I don't know why, but I didn't succeed according to their practice. Try again later.
The easiest way is to install two mysql on one machine. The installation method is not much different from installing a mysql.
tar -zxvf mysql-5.6.24.tar.gz
cd mysql-5.6.24
First Mysql, port 3306:
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
make
make install
Second Mysql, port 3307:
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql3307 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql3307/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql3307/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3307
make
make install
Change ownership:
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql3307
chown -R mysql:mysql /usr/local/mysql3307/data
Initialize:
cd /usr/local/mysql
./ scripts/mysql_install_db --user=mysql
cd /usr/local/mysql3307
./ scripts/mysql_install_db --user=mysql
Add to service list:
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf3306
cp /usr/local/mysql3307/support-files/mysql.server /etc/init.d/mysql3307
cp /usr/local/mysql3307/support-files/my-default.cnf /etc/my.cnf3307
Start Services:
service mysql start
service mysql3307 start
Check whether the service is started:
netstat -tlnap|grep mysql
Change the password of root user:
./ usr/local/mysql/bin/mysqladmin -u root password 'root';
./ usr/local/mysql3307/bin/mysqladmin -u root password 'root';
Landing:
mysql -S /usr/local/mysql/mysql.sock -P 3306 -uroot -p
mysql -S /usr/local/mysql3307/mysql.sock -P 3307 -uroot -p
The above content is how to install two Mysql on one machine. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.