1.正常安装Windows版的MySQL,例如安装在C:\Program Files\MySQL文件夹里;
2.按照常规配置好MySQL;
(注:5.6版本的 data文件夹与 my.ini文件在C:\ProgramData\MySQL\MySQL Server 5.6这个路径下面 )
3.复制备份安装好的文件夹,命名为“MySQL_3307"(C:\Program Files\MySQL文件夹与C:\ProgramData\MySQL都要复制); 删除 data目录下的文件其他文件夹,只剩 test和mysql文件夹;
4.修改“d:\MySQL_3307" 下的my.ini 端口为3307(5.6版本的Mysql的my.ini在隐藏文件ProgramData里面)
Java代码
[client]
no-beep
# pipe
# socket=0.0
port=3307
[mysql]
default-character-set=utf8
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
# server_type=3
[mysqld]
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe
# shared-memory
# shared-memory-base-name=MYSQL
# The Pipe the MySQL Server will use
# socket=MYSQL
# The TCP/IP Port the MySQL Server will listen on
port=3307
# Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL_3307/MySQL Server 5.6/"
# Path to the database root
datadir=C:/ProgramData/MySQL_3307/MySQL Server 5.6/Data
5.在cmd命令行模式下,进入第2个MySQL_3307的\bin文件夹。
执行mysqld install MySQL_3307命令。作用是为Mysql安装一个服务,服务名是MySQL_3307,
6.完毕后,在运行里运行REGEDIT,打开WINDOWS注册表编辑器,
在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MySQL_3307打开,
修改下面的ImagePath数值: "C:\Program Files\MySQL_3307\MySQL Server 5.6\bin\mysqld" --defaults-file="C:\ProgramData\MySQL_3307\MySQL Server 5.6\my.ini" MySQL_3307
确定,退出注册表编辑器。
7.然后就可以在服务管理里正常启动MySQL_3307服务。
注:若想重命名mysql服务名称,
1.进入services.msc关闭MySQL服务
2.C:\>sc delete MySQL “MySQL”为服务名称
3.重复上面的第6、7步即可
删除服务后,进入到注册表里,看旧的mysql节点是否删除。