Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install two Mysql on one machine

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report