一、删除原来的MySQL
-
删除 C:\Programs Files、C:\Programs Files(x86)、C:\ProgramData 中的所有MySQL目录
- 找到MySQL数据库中的data保存到其他位置,升级后可以恢复数据库数据 【备份数据】
-
删除注册表中MySQL的信息
计算机\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\EventLog\Application
下的MySQL
-
删除服务中的MySQL
- 以管理员的方式启动 cmd, 执行
sc delete MySQL80
或sc delete MySQL
这个根据自己MySQL的服务名视情况而定
- 以管理员的方式启动 cmd, 执行
二、下载安装MySQL
- 点击跳转官网下载
- 选择 Custom,正常的都下一步默认,设置密码别忘了,选择安装的时候我除了最后两个都安装了
三、配置
-
默认安装在 C:\Programs Files, 去这个文件夹找 MySQL 然后找 MySQL Server 8.0
-
打开环境变量,在系统变量中修改 MYSQL_HOME 或者添加,内容为
C:\Program Files\MySQL\MySQL Server 8.0\bin
【安装目录】 -
这个
C:\Program Files\MySQL\MySQL Server 8.0
目录下有个 my.ini 文件,如果没有就新建一个# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_bin init_connect='SET NAMES utf8mb4' # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # 下面这俩是工作目录和数据存储目录,自己视情况而定 basedir = D:\MySQL datadir = D:\MySQL\data port = 3306 # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 16M read_rnd_buffer_size = 16M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
-
然后打开 dos 控制台,输入
mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 8.0\my.ini"
【创建MySQL服务】
之后就可以正常使用我们的 MySQL 了
# 查看版本
mysql --version
# 登录mysql
mysql -u root -p
# 然后输入你的密码
如果使用Navicat 连接 MySQL 出现报错
- 那么可以在dos中登录mysql
- 然后执行
ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY '你想用的mysql登录密码';
【修改加密方式】