1.下载MySQL软件包并解压
2.配置环境变量
3.新建my.ini文件并输入信息
[mysqld]
#端口号
port = 3306
#mysql-5.7.27-winx64的路径
basedir=C:\mysql-5.7.37\mysql-5.7.37-winx64
#mysql-5.7.27-winx64的路径+\data
datadir=C:\mysql-5.7.37\mysql-5.7.37-winx64\data
#最大连接数
max_connections=200
#编码
character-set-server=utf8default-storage-engine=INNODBsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES[mysql]
#编码
default-character-set=utf8
4.以管理员身份运行cmd 输入下载命令安装MySQL
mysqld -installmysqld --initializemysqld --initializenet start mysql
注意:如果出现以下错误 那么我们需要去下载一下所需要的文件
下载地址:https://www.microsoft.com/zh-CN/download/details.aspx?id=40784
5.修改密码
skip-grant-tables 将其添加在my.ini文件中 net stop mysql 重启一下mysqlnet start mysqlmysql -u root -p 直接回车回车use mysqlupdate user set authentication_string=password("123456") where user="root";
然后在my.ini中删掉这句话 保存退出
6.停掉MySQL服务-MySQL 右键停止
7.再次登录mysql
C:\mysql-5.7.37\mysql-5.7.37-winx64\bin> net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。C:\mysql-5.7.37\mysql-5.7.37-winx64\bin> mysql -u root -p
Enter password: 123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37Copyright (c) 2000, 2022, Oracle and/or its affiliates.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> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.use mysql报错 我们重置一下密码
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.00 sec)mysql> use mysql
Database changed
mysql>
重置密码 大功告成