MySQL5.7.37安装配置

1.下载MySQL软件包并解压

2.配置环境变量

3.新建my.ini文件并输入信息

bash 复制代码
[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=utf8
 
default-storage-engine=INNODB
 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 
[mysql]
#编码
default-character-set=utf8 
 

4.以管理员身份运行cmd 输入下载命令安装MySQL

sql 复制代码
mysqld -install

mysqld --initialize

mysqld --initialize

net start mysql

注意:如果出现以下错误 那么我们需要去下载一下所需要的文件

下载地址:https://www.microsoft.com/zh-CN/download/details.aspx?id=40784

5.修改密码

java 复制代码
skip-grant-tables 将其添加在my.ini文件中 


net stop mysql  重启一下mysql

net start mysql

mysql -u root -p  直接回车回车

use mysql


update user set authentication_string=password("123456") where user="root";

然后在my.ini中删掉这句话 保存退出

6.停掉MySQL服务-MySQL 右键停止

7.再次登录mysql

java 复制代码
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.37

Copyright (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>

重置密码 大功告成

相关推荐
特种加菲猫25 分钟前
硬件与软件的桥梁:冯诺依曼体系、操作系统和初始进程的深度解析
linux·笔记
云和数据.ChenGuang1 小时前
关闭 GitLab 升级提示的详细方法
运维·自动化·gitlab·es运维
007php0071 小时前
服务器上PHP环境安装与更新版本和扩展(安装PHP、Nginx、Redis、Swoole和OPcache)
运维·服务器·后端·nginx·golang·测试用例·php
冰橙子id5 小时前
linux-远程访问管理(sshd,scp,sftp)
linux·网络·ssh
光电的一只菜鸡6 小时前
ubuntu之坑(十五)——设备树
linux·数据库·ubuntu
saynaihe8 小时前
ubuntu 22.04 anaconda comfyui安装
linux·运维·服务器·ubuntu
企鹅与蟒蛇8 小时前
Ubuntu-25.04 Wayland桌面环境安装Anaconda3之后无法启动anaconda-navigator问题解决
linux·运维·python·ubuntu·anaconda
小蜜蜂爱编程8 小时前
ubuntu透网方案
运维·服务器·ubuntu
程序设计实验室8 小时前
小心误关了NAS服务器!修改Linux的电源键功能
linux·nas
AI视觉网奇9 小时前
git 访问 github
运维·开发语言·docker