测试环境:window10,已经安装了mysql5.5,继续安装mysql8.0
两个mysql的安装都是自定义目录,我目录是D:\mysql5.5和D:\mysql8.0
5.5已经安装好了,默认端口是3306,所以第二个需要改一下端口,这里改为3307
先修改mysql8.0目录下的配置文件,建立文件,my.ini,在里面配置
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:\mysql8.0
datadir = D:\mysql8.0\data
port = 3307
server_id = 1
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
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忘记密码怎么办?