win10之mysql server 8.0.41安装

发布于:2025-04-02 ⋅ 阅读:(14) ⋅ 点赞:(0)

一 mysql server 下载

官网下载地址页面

https://dev.mysql.com/downloads/mysql/

在这里插入图片描述

二 免装版使用步骤

1 解压

下载完成后,解压文件夹,如下所示:
在这里插入图片描述

2 执行安装命令

D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>mysqld --install
Service successfully installed.

3 初始化mysql

D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>mysqld --initialize --console
2025-03-31T02:30:43.318917Z 0 [System] [MY-013169] [Server] D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin\mysqld.exe (mysqld 8.0.41) initializing of server in progress as process 8224
2025-03-31T02:30:43.344538Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-03-31T02:30:44.019707Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-03-31T02:30:46.985785Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: :W*Vd?:b123*

初始化会产生一个随机密码,在最后一行显示,记住这个密码,登录会用到

4 开启服务

D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

5 登录

D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>mysql -u root -h localhost -p

三 问题处理

在登录时候,可能会遇到一个问题,如下:

D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>mysql -u root -h localhost -p
Enter password: **
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
解决步骤
# 关闭服务
net stop mysql

# 通过控制台跳过密码表的加载和检查操作(不要关闭此CMD页面,另外以管理员身份打开CMD,然后输入mysql -u root,如果要求输入命令直接按Enter键跳过)
mysqld --console --skip-grant-tables --shared-memory

另外一个cmd窗口连接mqsql后,进行修改密码

D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.41 MySQL Community Server - GPL

Copyright (c) 2000, 2025, 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>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.01 sec)

五 服务开启自启

在安装的bin目录下执行命令

D:\soft\mysql\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>sc config mysql start=auto
[SC] ChangeServiceConfig 成功

在这里插入图片描述