同一台win系统下安装多个版本的mysql

window10系统下同时安装多个版本的Mysql

测试环境:window10,已经安装了mysql5.5,继续安装mysql8.0或者mysql5.7

两个mysql的安装都是自定义目录,我目录是D:\mysql5.5和D:\mysql8.0

5.5已经安装好了,默认端口是3306,所以第二个需要改一下端口,这里改为3307

首先,需要先修改mysql8.0目录下的配置文件,建立文件,my.ini,在里面配置

   # For advice on how to change settings please see

  1. # http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

  2. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

  3. # *** default location during install, and will be replaced if you

  4. # *** upgrade to a newer version of MySQL.

  5. [mysqld]

  6. # Remove leading # and set to the amount of RAM for the most important data

  7. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

  8. innodb_buffer_pool_size = 128M

  9. # Remove leading # to turn on a very important data integrity option: logging

  10. # changes to the binary log between backups.

  11. # log_bin

  12. # These are commonly set, remove the # and set as required.

  13. basedir = D:\mysql8.0\mysqld.exe

  14. datadir = D:\mysql8.0\data

  15. port = 3307

  16. server_id = 1

  17. # Remove leading # to set options mainly useful for reporting servers.

  18. # The server defaults are faster for transactions and fast SELECTs.

  19. # Adjust sizes as needed, experiment to find the optimal values.

  20. join_buffer_size = 128M

  21. sort_buffer_size = 2M

  22. read_rnd_buffer_size = 2M

  23. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

然后用管理员方式打开cmd,找到mysql8.0的bin目录下

输入mysqld --defaults-file=D:\mysql8.0\my.ini --initialize --console初始化一下,执行完这个命令会发现多了一个data文件夹

注意别忘记这个密码了,先复制下来。

然后执行mysqld install MySQL3  --defaults-file="D:\mysql8.0\my.ini"   然后返回成功。

接着win+r打开compmgmt.msc管理,找到MySQL3(自己定义的名字)启动就行了。

启动后使用navicat连接

报  

your password has expired   密码过期了

打开管理员cmd,进入安装mysql的目录下边,bin目录,输入

mysql -uroot -p -P3307    (自己设置的端口)

然后设置密码   set password = password('root');然后发现可以成功连接

假如你还是忘记了这个密码,看这里 mysql8忘记密码怎么办?

猜你喜欢

转载自blog.csdn.net/qq_39157951/article/details/85375352