MySQL的安装与卸载

MySQL的安装与卸载

注意这里启用cmd建议使用管理员身份启动,否则可能会出现拒绝停止MySQL服务的。

复制代码
C:\WINDOWS\system32>net stop mysql

卸载

检查自己的环境变量有没有之前残留的MySQL的环境变量

或者对此电脑(我的电脑)右键选择属性,然后选择高级系统设置

选择环境变量,在系统变量下找到Path双击进去

然后找到MySQL相关的选择它删除

然后删完后,一直确定直到窗口都关闭了

在cmd将MySQL服务也删除

对于解压版

在停掉MySQL服务后直接删掉MySQL所在的文件夹就可以了。

对于程序安装版

进入设置中的应用和功能进行卸载即可

安装版的删除过程

1.在控制面版,删除程序中直接卸载

2.删除mysql的隐藏文件 C:\ProgramData 需要手动输入 删除mysql这个文件

安装

对于解压版

解压下载后的压缩包

!CAUTION

但是注意路径中不要出现中文

配置MySQL对应的系统中的环境变量
在安装目录下新建一个my.txt记事本文件,进行MySQL的配置

在里面编写MySQL的配置

复制代码
[mysqld]
# skip_grant_tables
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\\mysql\\mysql-8.0.26-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\\mysql\\mysql-8.0.26-winx64\\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用"mysql_native_password"插件认证
default_authentication_plugin=mysql_native_password
[client]
#password = your_password
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4

对于程序安装版

这个有图形化引导安装

不做过多阐述

跟随引导进行下一步安装即可

初始化MySQL

cmd 复制代码
C:\WINDOWS\system32>mysqld --install mysql			#安装MySQL服务
Service successfully installed.

C:\WINDOWS\system32>mysqld --initialize --console	#初始化MySQL
2025-10-24T11:05:08.282616Z 0 [System] [MY-013169] [Server] D:\mysql\mysql-8.0.26-winx64\bin\mysqld.exe (mysqld 8.0.26) initializing of server in progress as process 30100
2025-10-24T11:05:08.296457Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-10-24T11:05:08.667968Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-10-24T11:05:09.371372Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-10-24T11:05:09.371656Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-10-24T11:05:09.397002Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: K.l.klz7qF-/

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


C:\WINDOWS\system32>mysql -uroot -pK.l.klz7qF-/		#登录MySQL

更改初始化的临时密码

mysql 复制代码
mysql> alter user root@localhost identified by '你想要的密码';

测试密码改成功没

复制代码
mysql> alter user root@localhost identified by 'r00t';
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye

C:\WINDOWS\system32>mysql -uroot -pr00t
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.26 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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.
相关推荐
韩家阿杰5 小时前
RabbitMQ技术的使用
1024程序员节
CoderYanger19 小时前
动态规划算法-简单多状态dp问题:15.买卖股票的最佳时机含冷冻期
开发语言·算法·leetcode·动态规划·1024程序员节
CoderYanger20 小时前
递归、搜索与回溯-FloodFill:33.太平洋大西洋水流问题
java·算法·leetcode·1024程序员节
CoderYanger1 天前
动态规划算法-斐波那契数列模型:2.三步问题
开发语言·算法·leetcode·面试·职场和发展·动态规划·1024程序员节
CoderYanger1 天前
动态规划算法-简单多状态dp问题:16.买卖股票的最佳时机含手续费
开发语言·算法·leetcode·动态规划·1024程序员节
CoderYanger1 天前
C.滑动窗口-求子数组个数-越短越合法——3258. 统计满足 K 约束的子字符串数量 I
java·开发语言·算法·leetcode·1024程序员节
CoderYanger1 天前
动态规划算法-路径问题:9.最小路径和
开发语言·算法·leetcode·动态规划·1024程序员节
CoderYanger1 天前
动态规划算法-路径问题:7.礼物的最大价值
开发语言·算法·leetcode·动态规划·1024程序员节
CoderYanger1 天前
动态规划算法-简单多状态dp问题:12.打家劫舍Ⅱ
开发语言·算法·leetcode·职场和发展·动态规划·1024程序员节
金融小师妹1 天前
机器学习驱动分析:ADP就业数据异常波动,AI模型预测12月降息概率达89%
大数据·人工智能·深度学习·编辑器·1024程序员节