【mysql】windows下 mysql 5.7 升级到8.0

mysql 5.7 升级到8.0

  • 下载mysql 8.0绿色版

    • MySQL :: Download MySQL Community Server

    在这里插入图片描述

  • 将下载的包解压到C盘:

    • C:\Program Files\MySQL\mysql-8.0.33-winx64
  • 配置环境变量,更改MYSQL_HOME的值

【mysql】windows下 mysql 5.7 升级到8.0_第1张图片

  • 删除5.7服务

    • 查找mysql57
    C:\Program Files\MySQL\mysql-8.0.33-winx64\bin>sc query mysql57
    
    SERVICE_NAME: mysql57
            TYPE               : 10  WIN32_OWN_PROCESS
            STATE              : 4  RUNNING
                                    (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
            WIN32_EXIT_CODE    : 0  (0x0)
            SERVICE_EXIT_CODE  : 0  (0x0)
            CHECKPOINT         : 0x0
            WAIT_HINT          : 0x0
    
    • 删除mysql57服务
    C:\Program Files\MySQL\mysql-8.0.33-winx64\bin>sc delete mysql57
    [SC] DeleteService 成功
    
  • 创建mysql80服务

    • 初始化服务
    C:\Program Files\MySQL\mysql-8.0.33-winx64\bin>mysqld --initialize --user=mysql --console
    2023-04-20T07:53:17.605901Z 0 [System] [MY-013169] [Server] C:\Program Files\MySQL\mysql-8.0.33-winx64\bin\mysqld.exe (mysqld 8.0.33) initializing of server in progress as process 6556
    2023-04-20T07:53:17.677427Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2023-04-20T07:53:24.766864Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2023-04-20T07:53:28.663340Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: aBjjrs_wp9l*
    
    • 需要注意初始化命令最后生产的初始密码:A temporary password is generated for root@localhost: aBjjrs_wp9l*
    • 安装服务mysql80
    C:\Program Files\MySQL\mysql-8.0.33-winx64\bin>mysqld -install MySql80
    Service successfully installed.
    
    • 启动服务
    C:\Program Files\MySQL\mysql-8.0.33-winx64\bin>net start MySql80
    MySql80 服务正在启动 ...
    MySql80 服务已经启动成功。
    
  • 此时服务安装完成,通过mysql -uroot -p 命令使用前面生成的初始登录

    • 登录后可修改密码:
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
    

你可能感兴趣的:(FAQ,MySQL,mysql,windows,数据库)