1. 解压
2. 环境变量
新增环境变量 MYSQL_HOME
追加环境变量 PATH
3. 配置文件内容
# 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]
# 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:\workingSoftware\mysql-5.7.17-winx64
datadir = D:\workingSoftware\mysql-5.7.17-winx64\data
# port = .....
# 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
安装和初始化
进入 mysql 的 bin 文件夹以管理员身份运行 cmd
执行
mysqld install
,在服务中会出现 MySQL 服务(如果不用管理员身份运行,将会因为权限不够而出现错误:Install/Remove of the Service Denied!)
(Windows 移除服务命令:sc delete mysql)
执行
mysqld --initialize --console
(此时会在 mysql 根目录下生成 data 文件夹)
“qZ*Hyh=-u59=”
为 root 账号初始密码,记住这个密码。
如果忘记或者没记住,删掉初始化的 data 目录,再执行一遍初始化命令(mysqld --initialize --console)
,又会重新生成。当然也可以使用安全工具强制改密码,用什么方法,自己随意。
启动 MySQL
cmd 中继续输入
net start mysql
启动 mysql停止 MySQL:
net stop mysql
修改 MySQL 账号密码
登录
(密码是生成的 “qZ*Hyh=-u59=”)
:
mysql -uroot -p
修改密码执行以下命令:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
flush privileges;