linux下安装多个mysql实例(摘自国外:How to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4)
How to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4
from:http://sharadchhetri.com/2013/12/02/create-multiple-mysql-instance-centos-6-4-red-hat-6-4/
December 2, 2013 by sharad chhetri 6 Comments
In this tutorial we will learn about how to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4. Multiple instance means in single system we can create multiple MySQL server. These multiple mysql server will run in different ports.In this practical we expect you already have MySQL server installed in your system.

To create multiple MySQL instance,follow the given below steps
Login as a root in a system
Step (1): Create a new MySQL data directory.
mkdir -p /var/lib/mysql2
Step 2: Now give permission and ownership .Here we are taking ownership and permission reference from original /var/lib/mysql data directory.
Note: /var/lib/mysql is bydefault data directory path
chmod --reference /var/lib/mysql /var/lib/mysql2 chown --reference /var/lib/mysql /var/lib/mysql2
Step 3: Now create a new my2.cnf file and paste the below given contents. We will run the new mysql instance in port no. 3337.
Copy the my.cnf file and make it blank
cp -p /etc/my.cnf /etc/my2.cnf
Now edit with vi editor or your favorite editor.
vi /etc/my2.cnf
Edit in [mysqld] and [mysqld_safe] section as given below in my2.cnf file
[mysqld] datadir=/var/lib/mysql2 socket=/var/lib/mysql/mysql2.sock port=3337 [mysqld_safe] log-error=/var/log/mysqld2.log pid-file=/var/run/mysqld/mysqld2.pid
Step 4: Now install the database in the new mysql data directory
mysql_install_db --user=mysql --datadir=/var/lib/mysql2
Below given is the output from my server (as a Reference)(下面的日志信息可能不一样,我安装是就不一样)
[root@localhost etc]# mysql_install_db --user=mysql --datadir=/var/lib/mysql2 Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [root@localhost etc]#
Step 5: Now the new instance is ready.Now in below section we will learn how to start,stop the mysql instance and how to connect with it.
Note: new mysql instance is running in port no. 3337 as per this tutorial
To start new mysql instance,use below given command
mysqld_safe --defaults-file=/etc/my2.cnf &
Now check the port no. 3337 is listening or not
netstat -tanp |grep 3337
To connect new mysql instance
Syntax: mysql -u username -p -h 127.0.0.1 -P port-no.
As per our tutorial:
mysql -u root -p -h 127.0.0.1 -p 3337
It will ask password,hit enter because root password is blank
Now set root password (It is upto your choice, for security reason it is recommended).You can see mysql prompt.
mysql > use mysql;
mysql > update user set password=PASSWORD("Give-here-new-root-PASSWORD") where User='root';
mysql > flush privileges;
mysql > exit
Recheck if MySQL root password is applied or not
mysql -u root -p -h 127.0.0.1 --port 3337 //这里原来是-p 3337,正确是--port 3337
To stop new mysql instance use below given command
mysqladmin -S /var/lib/mysql/mysql2.sock shutdown -p
Note: By using same method you can create multiple instance ,only you have to change the values like mysql2 to mysql3 or so on
linux下安装多个mysql实例(摘自国外:How to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4)的更多相关文章
- [Linux]Linux下安装和配置solr/tomcat/IK分词器 详细实例二.
		
为了更好的排版, 所以将IK分词器的安装重启了一篇博文, 大家可以接上solr的安装一同查看.[Linux]Linux下安装和配置solr/tomcat/IK分词器 详细实例一: http://ww ...
 - 在Linux下安装和使用MySQL
		
[简 介] 想使用Linux已经很长时间了,由于没有硬性任务一直也没有系统学习,近日由于工作需要必须使用Linux下的MySQL.本以为有Windows下使用SQL Server的经验,觉得在Linu ...
 - (转载)Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记
		
Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程 ...
 - 【云服务器部署】---Linux下安装MySQL
		
[云服务器部署]---Linux下安装MySQL 有关如何阿里云ECS建网站,推荐一片文章,我是是通过这篇文章安装tomcat和jdk的 网址:阿里云ECS建网站(建站)超详细全套完整图文教程! 注意 ...
 - Linux下安装JDK,Tomcat,Mysql详细教程
		
1. 概述 今天教大家在linux下安装jdk,mysql以及tomcat.在javaweb开发中,最后完成的项目代码,一般都是布在linux服务器下的.因为linux服务器可以说是安全性稳定性都比w ...
 - 在linux下安装并配置mysql数据库
		
在linux下安装并配置mysql数据库 工具/原料 MySql5.6 CentOS 方法/步骤 1 查找以前是否安装有mysql,使用下面命令: rpm -qa|grep -i mysql ...
 - Linux 下安装mysql 5.7
		
Linux 下安装mysql 5.7 本人首次安装时按照菜鸟教程的步骤一步一步来的,结果意外的是 装成5.6了,而且各种无厘头的问题,例如无法启动... 本文参照 大佬:‘这个名字想了很久~’ 的&l ...
 - Linux下安装配置与使用MySQL数据库
		
Linux下安装配置与使用MySQL数据库 在Linux下安装做开发时往往少不了要使用到MySQL数据库,下面就Linux系统为例讲解一下,如何安装MySQL数据库,如何启用/停.止MySQL服务,如 ...
 - linux下安装mysql(rpm文件安装)
		
数据库包下载: https://www.mysql.com/downloads/ 在GPL开原协议的社区开源版里边下载 我们用mysql community server里边的 其中workbench ...
 
随机推荐
- Makefile第二讲:打印出内容和使用变量
			
摘要 `@echo "开始生成最终执行文件,请稍候..."`这一句便是将一条信息输出到终端,为何前边有个`@`符号呢?有了这个符号该命令本身就不会输出到终端(不理解,自己去掉或者加 ...
 - 海量jQuery插件
			
转自:http://blog.csdn.net/zzq58157383/article/details/6900142 提醒大家在使用的时候注意jQuery包的版本问题,最好是使用相同的版本,因为使用 ...
 - android学习——项目的目录结构
			
学习开发之前要了解工程目录下的文件夹下文件的用意,是以HelloWorld为例: 1.HelloWorld项目的目录结构 1.1.src文件夹 1.2.gen文件夹 1.3.Android 2.1文件 ...
 - linux 命令拾遗
			
man ascii 这个命令会打印出八进制.十六进制和十进制的ASCII码表. xxd xxd可以生成所给与文件的十六进制拷贝,也可以将编辑好的十六进制拷贝还原成二进制格式.它也可以将十六进制拷贝输出 ...
 - POJ 3186Treats for the Cows (区间DP)
			
详见代码 #include <stdio.h> #include <algorithm> #include <string.h> using namespace s ...
 - WORD文档的长串数字如何粘贴到excel
			
有问题,才有提高 问题描述: 现 word 文档中有好多长长的数字(如下),我需要将它们弄进 Excel 中 直接[复制],[粘贴],结果显示如下: 然后再设置单元格格式中的数字,无论选哪一个都得不到 ...
 - Vi和Vim的区别及联系
			
它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅兼容vi的所有指令,而且还有一些新的特性在里面.vim的这些优势主要体现在以下几个方面:1.多级撤消我们知道在vi里,按 u只能撤消上次命 ...
 - Maven source jar  get
			
Maven作为项目管理的包,同时也能方便的将source-jar下载的本地,省去了每次到网上分别下载的问题. Maven下载Jar包同时下载源文件和文档 示例,在maven生成的工程里面:mvn ec ...
 - appium
			
电话键 KEYCODE_CALL 拨号键 5KEYCODE_ENDCALL 挂机键 6KEYCODE_HOME 按键Home 3KEYCODE_MENU 菜单键 82KEYCODE_BACK 返回键 ...
 - 20169210《Linux内核原理与分析》第十二周作业
			
Return-to-libc 攻击实验 缓冲区溢出的常用攻击方法是用 shellcode 的地址来覆盖漏洞程序的返回地址,使得漏洞程序去执行存放在栈中 shellcode.为了阻止这种类型的攻击,一些 ...