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

Mysql Multi-instance launch brief memo

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mysql multi-instance configuration scheme:

Scenario 1 (multiple profiles, multiple startup programs):

Mkdir / data/3306/ {data,tmp,log} touch my.cnf

Service file mysql change port

(1) installation depends on ncurses-devel libaio-devel

(2) example of configuration file

[client] port=3306socket=/data/3306/ mysql.sock[mysql] no-auto- rehash[mysqld] user=mysqlport=3306socket=/data/3306/mysql.sockbasedir=/usr/local/mysqldatadir=/data/3306/dataopen_files_limit=1024back_log=600log-error=/data/3306/log/error.logslow_query_log=onslow_query_log_file=/data/3306/log/slow.logpid-file=/data/3306/mysql.pidlog-bin=/data/3306/log/mysql-binserver-id= 1[mysqld _ safe] log-error=/data/3306/log / error.logpid-file=/data/3306/mysql.pid

(3) initialization

In the new version of chown-R mysql:mysql / datamysql_install_db-- user=mysql-- basedir=/usr/local/mysql-- datadir=/data/3306/data#, it is recommended to use mysqld-- initialize--user=mysql-- basedir=/usr/local/mysql-- datadir=/home/mysql. If-- initialize is changed to-- initialize-insecure during initialization, an root@localhost account with an empty password will be created, otherwise a root@localhost account with a password will be created to create log files and change permissions.

(4) start multiple instances

Mysqld_safe-- defaults-file=/data/3306/my.cnf & > / dev/null &

Or start using the copied mysql

Log in: mysql-S / data/3306/mysql.sock

Multi-instance stop

Mysqladmin-u root-p "password"-S / data/3306/mysql.sock shutdown

Option 2: single profile

(1) example of configuration file my_multi.cnf

[mysqld_multi] mysqld=/usr/bin/mysqld_safemysqladmin=/usr/bin/mysqladminuser= mysql[mysqld1] socket=/var/lib/mysql/mysql.sockport=3306pid-file=/var/lib/mysql/mysql.piddatadir=/var/lib/mysqluser=mysql [mysqld2] socket=/data/3307/mysql.sockport=3307pid-file=/data/3307/mysql.piddatadir=/data/3307/datauser=mysqlserver-id=10defautlt-storage-engine= innodb[mysqld3]...

(2) Startup method

Mysqld_multi-- config-file=/data/mysql/my_multi.cnf {start | stop | report} 1, 2, 3, 4-6, 7

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