1.去官网下载MySQL,选择合适的版本
2.解压
3.配置系统环境变量(便于操作)
4.在mysql根目录新建my.ini[似乎是mysql5.5以上版本已无my.ini文件和data文件夹]
默认的my.ini如下
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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:\Program Files\mysql-5.7.20-winx64
datadir = D:\Program Files\mysql-5.7.20-winx64\data
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 values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
5.管理员权限打开cmd,cd到mysql的bin目录执行mysqld -install
6.Service successfully installed后紧接着执行mysqld --initialize --user=mysql --console
7.在上个命令执行的结果最后一行可以发现mysql的root用户临时密码【在localhost后面】
于是,mysql装好了
然后启动服务吧,接着执行命令net start mysql
cmd黑框框里提示启动成功。显示如下信息
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
执行mysql -u root -p输入临时密码登录。然后去修改密码吧
当然,改密码也是有可能要碰到问题的。
我们知道,改密码确实有多种方式,然而当你输入update mysql.user set authentication_string=password('your new password') where user='root' and Host = 'localhost';时给你报ERROR 1820错误,所以执行alter user 'root'@'localhost' identified by 'your new password';改密完成。【注:新版MySQL密码字段已更改为authentication_string。】