MySQL卸载安装8.0.*
一、卸载
1. 本人安装目录在C盘Program Files文件中(删除MySQL文件夹)
2. 找到C盘Program Data隐藏文件夹中的MySQL并删除(删除提示MySQL在运行的话可以去任务管理器中杀死MySQL进程)
3. 卸载MySQL相关注册表,根据路径删除
打开注册表window+R:
根据路径打开并删除:
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Applications/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services/Eventlog/Applications/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Applications/MySQL
或者按F3或ctrl+F搜索MySQL(鼠标选中计算机)
至此完成卸载。。。。
二、MySQL安装步骤(解压版)
1. MySQL下载地址
https://dev.mysql.com/downloads/mysql/
2. 解压到MySQL压缩包
解压后目录需要创建my.ini文件与data文件夹(有的无需创建)
3. 修改my.ini文件:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir= D:\\BCSoftware\\mysql-8.0.13-winx64
# 设置mysql数据库的数据的存放目录
datadir= D:\\BCSoftware\\mysql-8.0.13-winx64\\data
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
注意修改时basedir与datadir这两个变量要写成自己的安装路径,目录中要使用双斜杠“\\”或反斜杠“/”来表示。
4. 配置环境变量
新建MYSQL_HOME变量,值为解压目录
在path中编辑上%MYSQL_HOME%\bin
5. 获取并修改root密码
管理员身份运行cmd
进入mysql解压文件中的bin目录下
执行mysqld install命令 (如果安装多个mysql数据库可以指定一下服务名:mysqld install mysql80 --defaults-file="D:\program\dev\mysql-8.0.25-winx64\my.ini")
执行mysqld --initialize --console命令
此时得到生成的mysql的root的密码
执行net start mysql命令启动mysql服务
执行mysql -u root -p命令登陆
然后把得到的密码复制到当前位置
登陆成功后执行 修改密码sql:
alter user 'root'@'localhost' identified with mysql_native_password by '新的密码';
附安装命令:
PS D:\program\dev\mysql-8.0.25-winx64\bin> mysqld install mysql80 --defaults-file="D:\program\dev\mysql-8.0.25-winx64\my.ini" Service successfully installed. PS D:\program\dev\mysql-8.0.25-winx64\bin> mysqld --initialize --console 2021-07-01T07:03:46.237547Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2021-07-01T07:03:46.238348Z 0 [System] [MY-013169] [Server] D:\program\dev\mysql-8.0.25-winx64\bin\mysqld.exe (mysqld 8.0.25) initializing of server in progress as process 1372 2021-07-01T07:03:46.345245Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-07-01T07:03:55.615647Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-07-01T07:04:19.395205Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: yt#gpq=1plgG PS D:\program\dev\mysql-8.0.25-winx64\bin> net start mysql80 mysql80 服务正在启动 ..... mysql80 服务已经启动成功。 PS D:\program\dev\mysql-8.0.25-winx64\bin> mysql -u root -p Enter password: ************ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.25 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. mysql> alter user 'root'@'localhost' identified with mysql_native_password by '新的密码'; Query OK, 0 rows affected (0.50 sec)
mysql> exit;
Bye
PS D:\program\dev\mysql-8.0.25-winx64\bin>