MySQL在Windows上安装多个实例的方法


Step 1: 解压MySQL安装包,配置my.ini文件,注意port不能设置为默认的3306,这里我们设置为3307端口:





点击(此处)折叠或打开



  1. basedir = E:\MySQL\mysql-5.7.17-win32
  2. datadir = E:\MySQL\mysql-5.7.17-win32\data
  3. log_bin
  4. server_id=5717
  5. port = 3307


 Step 2: 打开CMD窗口,进入到安装路径的bin目录,这里为:E:\MySQL\mysql-5.7.17-win32\bin,执行如下命令:





点击(此处)折叠或打开



  1. mysqld --initialize-insecure
  2. mysqld install MySQL5711

  Step 3:  执行成功后启动MySQL,并更新相应的密码,注意这里的初始密码为空



点击(此处)折叠或打开



  1. mysql -uroot -P3307 -p
  2. update mysql.user set authentication_string=password("lhr") where user="root";
  3. update mysql.user set Host="%" where Host="127.0.0.1";
  4. update mysql.user set Host="%" where Host="localhost";
  5. flush privileges

  Step 4:  验证登录:mysql -uroot -plhr -P3307




点击(此处)折叠或打开



  1. E:\MySQL\mysql-5.7.17-win32\bin>mysql -uroot -plhr -P3307
  2. mysql: [Warning] Using a password on the command line interface can be insecure.
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 5
  5. Server version: 5.7.17-log MySQL Community Server (GPL)
  6. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> status
  12. --------------
  13. mysql Ver 14.14 Distrib 5.7.17, for Win32 (AMD64)
  14. Connection id: 5
  15. Current database:
  16. Current user: root@localhost
  17. SSL: Not in use
  18. Using delimiter: ;
  19. Server version: 5.7.17-log MySQL Community Server (GPL)
  20. Protocol version: 10
  21. Connection: localhost via TCP/IP
  22. Server characterset: latin1
  23. Db characterset: latin1
  24. Client characterset: gbk
  25. Conn. characterset: gbk
  26. TCP port: 3307
  27. Uptime: 4 min 40 sec
  28. Threads: 1 Questions: 14 Slow queries: 0 Opens: 116 Flush tables: 1 Open tables: 109 Queries per second avg: 0.050
  29. --------------
  30. mysql> select @@version;
  31. +------------+
  32. | @@version |
  33. +------------+
  34. | 5.7.17-log |
  35. +------------+
  36. 1 row in set (0.00 sec)
  37. mysql>
  38. mysql> show variables like '%server_id%';
  39. +----------------+-------+
  40. | Variable_name | Value |
  41. +----------------+-------+
  42. | server_id | 5717 |
  43. | server_id_bits | 32 |
  44. +----------------+-------+
  45. 2 rows in set, 1 warning (0.02 sec)
  46. mysql> show variables like 'port';
  47. +---------------+-------+
  48. | Variable_name | Value |
  49. +---------------+-------+
  50. | port | 3307 |
  51. +---------------+-------+
  52. 1 row in set, 1 warning (0.01 sec)



 安装完毕。效果图:

MySQL在Windows上安装多个实例的方法_mysql





本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除


本文在itpub(http://blog.itpub.net/26736162/abstract/1/)和个人微信公众号(xiaomaimiaolhr)上有同步更新


QQ群号:230161599(满)、618766405


版权所有,欢迎分享本文载请保留出处


使用微信客户端扫描下面的二维码来关注小麦苗的微信公众号(xiaomaimiaolhr)及QQ群(DBA宝典)、添加小麦苗微信,学习最实用的数据库技术。

MySQL在Windows上安装多个实例的方法_.net_02