mysql多实例

##mysql多实例

	systemctl stop mysqld
	systemctl diable mysqld   暂停原有的MySQL服务
	mv /etc/my.cnf /opt       移除原有的
	mv mysql-5.7.20....  /usr/local/mysql

	vim /etc/my.cnf
		[mysqld_multi]   ===>/usr/local/mysql/mysqld_multi  文件
			mysqld=/usr/local/mysql/bin/mysqld_safe
			mysqladmin=/usr/local/mysql/bin/mysqladmin
			user=root

			[mysqld1]
				socket=/mysqld1.scok
				port=3307
				pid-file=mysqld1.pid
				log-error=mysqld1.err
				datadir=/dir1

			[mysqld2]
				socket=/mysqld2.scok
				port=3307
				pid-file=mysqld2.pid
				log-error=mysqld2.err
				datadir=/dir2
			
			mkdir /dir1 /dir2

	 	  启用多实例:
			/usr/local/mysql/bin/mysqld_multi start 1
			ps -C mysqld
			netstat -nutpl | grep :3307
		
		 停止多实例:
			mysqld_multi --user=root --password='密码' stop 1

你可能感兴趣的:(mysql多实例)