MySQL在Windows上安装多个实例的方法
Step 1: 解压MySQL安装包,配置my.ini文件,注意port不能设置为默认的3306,这里我们设置为3307端口:
点击(此处)折叠或打开
-  basedir = E:\MySQL\mysql-5.7.17-win32
 
- datadir = E:\MySQL\mysql-5.7.17-win32\data
- log_bin
- server_id=5717
- port = 3307
Step 2: 打开CMD窗口,进入到安装路径的bin目录,这里为:E:\MySQL\mysql-5.7.17-win32\bin,执行如下命令:
点击(此处)折叠或打开
-  mysqld --initialize-insecure
 
- mysqld install MySQL5711
Step 3: 执行成功后启动MySQL,并更新相应的密码,注意这里的初始密码为空
点击(此处)折叠或打开
-  mysql -uroot -P3307 -p
 
- update mysql.user set authentication_string=password("lhr") where user="root";
- update mysql.user set Host="%" where Host="127.0.0.1";
- update mysql.user set Host="%" where Host="localhost";
- flush privileges
Step 4: 验证登录:mysql -uroot -plhr -P3307
点击(此处)折叠或打开
-  E:\MySQL\mysql-5.7.17-win32\bin>mysql -uroot -plhr -P3307
 
- mysql: [Warning] Using a password on the command line interface can be insecure.
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 5
- Server version: 5.7.17-log MySQL Community Server (GPL)
- Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> status
- --------------
- mysql Ver 14.14 Distrib 5.7.17, for Win32 (AMD64)
- Connection id: 5
- Current database:
- Current user: root@localhost
- SSL: Not in use
- Using delimiter: ;
- Server version: 5.7.17-log MySQL Community Server (GPL)
- Protocol version: 10
- Connection: localhost via TCP/IP
- Server characterset: latin1
- Db characterset: latin1
- Client characterset: gbk
- Conn. characterset: gbk
- TCP port: 3307
- Uptime: 4 min 40 sec
- Threads: 1 Questions: 14 Slow queries: 0 Opens: 116 Flush tables: 1 Open tables: 109 Queries per second avg: 0.050
- --------------
- mysql> select @@version;
- +------------+
- | @@version |
- +------------+
- | 5.7.17-log |
- +------------+
- 1 row in set (0.00 sec)
- mysql>
- mysql> show variables like '%server_id%';
- +----------------+-------+
- | Variable_name | Value |
- +----------------+-------+
- | server_id | 5717 |
- | server_id_bits | 32 |
- +----------------+-------+
- 2 rows in set, 1 warning (0.02 sec)
- mysql> show variables like 'port';
- +---------------+-------+
- | Variable_name | Value |
- +---------------+-------+
- | port | 3307 |
- +---------------+-------+
- 1 row in set, 1 warning (0.01 sec)
安装完毕。效果图:

● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)和个人微信公众号(xiaomaimiaolhr)上有同步更新
● QQ群号:230161599(满)、618766405
● 版权所有,欢迎分享本文,转载请保留出处
使用微信客户端扫描下面的二维码来关注小麦苗的微信公众号(xiaomaimiaolhr)及QQ群(DBA宝典)、添加小麦苗微信,学习最实用的数据库技术。
 
 
                    
 
            
        













 
                    

 
                 
                    