window中安装mysql也是一个烦人的活 各种坑等着你跳
安装成功了 还是总结一下经验 以后还可以查看
1.下载mysql
MySQL :: Download MySQL Community Server
MySQL :: Download MySQL Community Server
http://119.96.250.129/mysql-5.7.32-winx64.zip
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.36-winx64.zip
选择要下载的mysql 这里选择window 64bit
无需登录,直接点击 No thanks, just start my download.
2.解压
刚解压出来的时候 是没有data文件夹的
3.配置环境变量
4.配置文件
修改mysql解压目录下的my-default.ini文件
# basedir =D:\mysql-5.7.17-winx64
# datadir =D:\mysql-5.7.17-winx64\data
# port = 3306
# server_id =10
# 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:\mysql-5.7.17-winx64
# datadir =D:\mysql-5.7.17-winx64\data
# port = 3306
# server_id =10
# 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.安装mysql
管理员方式运行cmd 执行mysqld --install MySQL --defaults-file="D:\mysql-5.7.17-winx64\my-default.ini"
6.初始化mysql
初始化mysql 有两种方式 msyql7默认使用mysqld --initialize 这是一种安全的方式 会给root用户生成一个随机密码,在首次登录后一定要修改用户密码才能操作,这也 体现了mysql7的安全性。
由于我不知道window下mysql随机密码怎么找到 所以我选择不安全的初始化方式mysqld --initialize-insecure 进去再修改root密码
7.启动mysql服务
net start mysql
8.登录
mysql -uroot -p
直接按回车 不需要输入密码
9.修改root密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');