win10安装mysql 5.7

win10安装mysql 5.7

下载mysql 5.7

mysql官方下载地址下载mysql
在这里插入图片描述
在这里插入图片描述

解压(路径:d:mysql5.7)
在这里插入图片描述

文件配置

在d:mysql5.7目录下新建my.ini文件和data文件夹,如上图所示。写入my.ini文件内容:

[client]
port=3306
default-character-set=utf8

[mysqld] 
basedir = "D:/mysql5.7"	# 设置为MYSQL的安装目录 
datadir = "D:/mysql5.7/data"	# 设置为MYSQL的数据目录 
port=3306
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
explicit_defaults_for_timestamp=true	#开启查询缓存

配置环境变量

在这里插入图片描述

开始敲命令

以管理员身份运行“命令提示符”
命令过程如下:

C:windowssystem32>mysqld -install      #安装mysql
Service successfully installed.

C:windowssystem32>mysqld --initialize-insecure      #mysql初始化

C:windowssystem32>net start mysql      #启动mysql服务
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

C:windowssystem32>mysql -uroot -p     #登录mysql
Enter password:       #密码为空
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> set password for root@localhost = password('root');    #修改root用户密码为“root”
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit   #退出mysql
Bye

C:windowssystem32>mysql -uroot -p      #再次登录测试
Enter password: ****         #密码为root登录成功
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> exit   #退出mysql
Bye

大功告成!!!

原文地址:https://www.cnblogs.com/AlexanderZhao/p/12978325.html