1.进入MySQL官网下载 mysql-5.7.15-winx64.zip
2.mysql-5.7.15-winx64.zip 解压到 D:\ 目录下,生成mysql-5.7.15-winx64文件夹
3.创建my.ini作为MySQL的配置文件
在 D:\mysql-5.7.15-winx64下,复制“my-default.ini”,将生成的文件重命名为“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]
# 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.15-winx64
datadir = D:\\mysql-5.7.15-winx64\\data
port = 3306
#自定义主机ID识别符,用于主从或多服务器之间识别,为 一个 int 类型
server_id = 1
character_set_server=utf8
# 最大连接数量
max_connections = 100
#CREATE TABLE 语句的默认表类型,如果不自己指定类型,则使用下行的类型
default-storage-engine = InnoDB
# 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
4.将D:\mysql-5.7.15-winx64\bin配置到环境变量path中
5.安装mysql为windows服务
D:\mysql-5.7.15-winx64\bin\mysqld.exe -install mysql
6.mysql 5.7+版本的根目录下缺少data文件夹,此时不要去拷贝其他版本的date文件夹,打开cmd命令窗口,并且进入到D:\mysql-5.7.15-winx64\bin目录中,输入以下命令:
mysqld --initialize-insecure --user=mysql
7.启动mysql服务:
net start mysql
8.登录修改mysql密码
cmd进入命令行
mysql -u root -p
回车 回车
进入数据库
usr mysql;
select host ,user,authentication_string from user;
update user set authentication_string=authentication_string('123456') where user='root';
flush privileges;
9.修改权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Linkgoo1409' WITH GRANT OPTION;