记录一次mysql5.7.26的安装,8.0+ 的数据库全是坑,没办法,换成5.7版本的了

想要换数据库版本前注意数据库的备份!!!

完全卸载之前的数据库操作步骤:

管理员运行cmd输入
net stop mysql //关闭mysql数据库
sc delete mysql //这里的mysql是你要删除的服务名,通过该命令就可以删除相关的服务。


正文开始:

  1. 下载安装,将文件解压至自己想放置的安装文件目录下
  2. 在安装文件目录下新建my.ini

mysql 5.7.26下的my.ini

[mysqld]
# 设置mysql客户端默认字符集
#default-character-set=utf8
character-set-server=utf8

[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\developer_tools\mysql-5.7.26-winx64
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
datadir=D:\developer_tools\mysql-5.7.26-winx64\data
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
#开启查询缓存
explicit_defaults_for_timestamp=true
  1. 管理员方式cmd控制台输入进行安装

注意:每次安装输入时需要删除data文件夹,否则报错

C:\Users\Wu Hao>D:
D:\>cd D:\developer_tools\mysql-5.7.26-winx64\bin
D:\developer_tools\mysql-5.7.26-winx64\bin>mysqld --initialize --console

出现密码则成功

D:\developer_tools\mysql-5.7.26-winx64\bin>mysqld --initialize --console
2019-07-21T03:58:21.517002Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-07-21T03:58:21.545346Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-07-21T03:58:21.639871Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c7f8dcbc-ab6b-11e9-829e-c46516bb90fd.
2019-07-21T03:58:21.645396Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-07-21T03:58:21.656469Z 1 [Note] A temporary password is generated for root@localhost: spmhoaqUy7=&

记录密码下次改密码需要

  1. 安装服务,启动服务
    如果出现错误,请用管理员方式输入命令。
D:\developer_tools\mysql-5.7.26-winx64\bin>mysqld install
Service successfully installed.

D:\developer_tools\mysql-5.7.26-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
  1. 将bin目录加到环境变量里

将D:\developer_tools\mysql-5.7.26-winx64\bin;加到环境变量path中

记录一次mysql5.7.26的安装,8.0+ 的数据库全是坑,没办法,换成5.7版本的了_第1张图片

  1. 登录mysql数据库并修改密码

cmd控制台输入
mysql -u root -p
将之前的密码输入进去

C:\Users\Wu Hao>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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 'root';
Query OK, 0 rows affected (0.00 sec)
  1. 测试,可以正常显示则成功安装
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

你可能感兴趣的:(数据库)