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)
安装完毕。效果图:
About Me
...............................................................................................................................
● 本文作者:小麦苗,只专注于数据库的技术,更注重技术的运用
● 本文在itpub(http://blog.itpub.net/26736162)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/viewspace-2136081/
● 本文博客园地址:http://www.cnblogs.com/lhrbest
● 本文pdf版及小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/
● QQ群:230161599 微信群:私聊
● 联系我请加QQ好友(646634621),注明添加缘由
● 于 2017-03-25 09:00 ~ 2017-03-25 22:00 在魔都完成
● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
...............................................................................................................................
拿起手机使用微信客户端扫描下边的左边图片来关注小麦苗的微信公众号:xiaomaimiaolhr,扫描右边的二维码加入小麦苗的QQ群,学习最实用的数据库技术。
|