MySQL 8 压缩包版(zip) 安装

  1. 最新版下载网址:https://dev.mysql.com/downloads/mysql/
  2. 历史版本下载网址:https://downloads.mysql.com/archives/community/
  3. 解压安装包:
    解压目录:
    D:\Program Files\mysql-8.0.25-winx64
    

     

  4. 增加配置文件 my.ini:
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/windows-create-option-file.html

    D:/Program Files/mysql-8.0.25-winx64/my.ini
    [mysqld]
    # set basedir to your installation path
    basedir=D:\Program Files\mysql-8.0.25-winx64
    # set datadir to the location of your data directory
    datadir=D:\ProgramData\MySQL-8.0.25-Data
    
  5. 初始化数据库:
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization.html
    1. 无密码初始化:
      mysqld --initialize-insecure --user=mysql --console
       
      Microsoft Windows [版本 10.0.19042.964]
      (c) Microsoft Corporation。保留所有权利。
      
      D:\Program Files\mysql-8.0.25-winx64\bin>mysqld --initialize-insecure --user=mysql --console
      2021-05-12T12:09:25.071351Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.25-winx64\bin\mysqld.exe (mysqld 8.0.25) initializing of server in progress as process 15960
      2021-05-12T12:09:25.080631Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
      2021-05-12T12:09:25.854184Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
      2021-05-12T12:09:27.296992Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
      
      D:\Program Files\mysql-8.0.25-winx64\bin>
      翻译:
      Microsoft Windows [版本 10.0.19042.964]
      (c) Microsoft Corporation。保留所有权利。
      
      D:\Program Files\mysql-8.0.25-winx64\bin>mysqld --initialize-insecure --user=mysql --console
      2021-05-12T12:09:25.071351Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.25-winx64\bin\mysqld.exe (mysqld 8.0.25) 正在将服务器初始化为进程15960
      2021-05-12T12:09:25.080631Z 1 [System] [MY-013576] [InnoDB] InnoDB 初始化已开始。
      2021-05-12T12:09:25.854184Z 1 [System] [MY-013577] [InnoDB] InnoDB 初始化已结束。
      2021-05-12T12:09:27.296992Z 6 [Warning] [MY-010453] [Server] root@localhost 是用空密码创建的!请考虑关闭 --initialize-insecure 选项。
      
      D:\Program Files\mysql-8.0.25-winx64\bin>
    2. 随机密码初始化:
      mysqld --initialize --user=mysql --console
      Microsoft Windows [版本 10.0.19042.964]
      (c) Microsoft Corporation。保留所有权利。
      
      D:\Program Files\mysql-8.0.25-winx64\bin>mysqld --initialize --user=mysql --console
      2021-05-12T12:19:06.540025Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.25-winx64\bin\mysqld.exe (mysqld 8.0.25) initializing of server in progress as process 16816
      2021-05-12T12:19:06.551245Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
      2021-05-12T12:19:07.305727Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
      2021-05-12T12:19:09.131024Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: qaXfshWdt9/+
      
      D:\Program Files\mysql-8.0.25-winx64\bin>
      翻译:
      Microsoft Windows [版本 10.0.19042.964]
      (c) Microsoft Corporation。保留所有权利。
      
      D:\Program Files\mysql-8.0.25-winx64\bin>mysqld --initialize --user=mysql --console
      2021-05-12T12:19:06.540025Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.25-winx64\bin\mysqld.exe (mysqld 8.0.25) 正在将服务器初始化为进程16816
      2021-05-12T12:19:06.551245Z 1 [System] [MY-013576] [InnoDB] InnoDB 初始化已开始。
      2021-05-12T12:19:07.305727Z 1 [System] [MY-013577] [InnoDB] InnoDB 初始化已结束。
      2021-05-12T12:19:09.131024Z 6 [Note] [MY-010454] [Server] 将为生成临时密码 root@localhost: qaXfshWdt9/+
      
      D:\Program Files\mysql-8.0.25-winx64\bin>
  6. 启动数据库:
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/starting-server.html
    mysqld --user=mysql &
  7. 连接数据库:
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/default-privileges.html
    mysql -u root -p
     
    D:\Program Files\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>
  8. 修改密码:
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/default-privileges.html
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql>
  9. 停止数据库(需要密码):
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/default-privileges.html
    mysqladmin -u root -p shutdown
     
    D:\Program Files\mysql-8.0.25-winx64\bin>mysqladmin -u root -p shutdown
    Enter password: *************
    
    D:\Program Files\mysql-8.0.25-winx64\bin>
  10. 添加环境变量:
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/mysql-installation-windows-path.html
    MYSQL_HOME="D:\Program Files\mysql-8.0.25-winx64"
    Path=%Path%;%MYSQL_HOME%\bin
  11. 安装MySQL为Windows服务:
    官方文档:https://dev.mysql.com/doc/refman/8.0/en/windows-start-service.html
    1. ​​​​​​​在将MySQL作为Windows服务安装之前,如果正在使用以下命令运行当前服务器,则应首先停止它:
      mysqladmin -u root -p shutdown
       
      Microsoft Windows [版本 10.0.19042.964]
      (c) Microsoft Corporation。保留所有权利。
      
      D:\Program Files\mysql-8.0.25-winx64\bin>mysqladmin -u root -p shutdown
      Enter password: *************
      
      D:\Program Files\mysql-8.0.25-winx64\bin>
    2. 将服务器作为服务安装(以管理员身份运行):
      mysqld --install
      Microsoft Windows [版本 10.0.19042.964]
      (c) Microsoft Corporation。保留所有权利。
      
      C:\Windows\system32>D:
      
      D:\>cd D:\Program Files\mysql-8.0.25-winx64\bin
      
      D:\Program Files\mysql-8.0.25-winx64\bin>mysqld --install
      Service successfully installed.
      
      D:\Program Files\mysql-8.0.25-winx64\bin>
  12. 查看服务:
  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值