Windows下安装的步骤:

  1. 下载mysql压缩包版本,建议从镜像云中下载

  2. 解压到安装目录下,建议全英文且路径中不能带空格

  3. 新建my.ini,此文件为mysql的配置文件

  4. 安装服务,初始化数据库,生成基础数据库

  5. 重置root用户密码


详细操作

1.my.ini模板

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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]
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 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.
#mysql安装路径
basedir =D:\ProgramCenter\mysql-5.7.15-winx64
#mysql的数据库存放路径
datadir =D:\ProgramCenter\mysql-5.7.15-winx64\data
#mysql服务默认端口
port = 3306
# server_id = .....
# 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
 join_buffer_size = 128M
 sort_buffer_size = 2M
 read_rnd_buffer_size = 2M 
#相关配置
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

2.安装服务,初始化数据库命令。首先创建数据库存放的文件夹,如果目录已存在,请清空该目录,然后以管理员权限打开cmd,进入mysql目录下的bin文件夹,执行以下命令:

#安装mysql
mysqld install

#初始化mysql数据库,并生成root用户
mysqld --initialize-insecure --user=mysql

#启动mysql
net start mysql

#登录mysql,密码为空
mysql -u root -p

3.修改root密码,可以使用navicat,也可以使用命令行,下面说一下使用命令行修改密码的命令

use mysql;
update user set authentication_string=password('root') where user='root';
flush privileges;