Windows 安装MySQL 8.0.25 压缩版

安装步骤

下载8.0.25(压缩版)

https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.25-winx64.zip

解压并设置

第一步:解压mysql-8.0.25-winx64.zip 至 C:\WindowsApplicaions\mysql-8.0.25-winx64

第二步:配置环境变量 环境-> Path -> 环境变量

第三步:编辑my.ini

[mysql]
default-character-set=utf8

[mysqld]
port=3306
basedir=C:\WindowsApplicaions\mysql-8.0.25-winx64
datadir=C:\WindowsApplicaions\mysql-8.0.25-winx64\data
character-set-server=utf8
default-storage-engine=INNODB
skip_grant_tables

my.ini 存放路径(非常重要!):C:\WindowsApplicaions\mysql-8.0.25-winx64\bin

第四步:初始化

C:\WindowsApplicaions\mysql-8.0.25-winx64\bin>mysqld --initialize --user=mysql --console
2023-03-22T06:45:22.360457Z 0 [System] [MY-013169] [Server] C:\WindowsApplicaions\mysql-8.0.25-winx64\bin\mysqld.exe (mysqld 8.0.25) initializing of server in progress as process 9992
2023-03-22T06:45:22.369162Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-03-22T06:45:22.838252Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-03-22T06:45:24.052125Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: TiBfhr5UkE%(

产生的临时密码:TiBfhr5UkE%(

第五步:安装mysql

mysqld --install

第六步:start mysql

net start mysql

第七步:登录

C:\WindowsApplicaions\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 9
Server version: 8.0.25

输入临时密码后,即可成功登录。

删除MySQL服务

查看MySQL服务

正常运行后,查看service会看到MySQL服务

C:\WindowsApplicaions\mysql-8.0.25-winx64\bin>sc query mysql

SERVICE_NAME: mysql
        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

通过命令可以看到服务详细信息

查看端口3306

C:\WindowsApplicaions\mysql-8.0.25-winx64\bin>netstat -ano | findstr "3306"
  TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       24164
  TCP    0.0.0.0:33060          0.0.0.0:0              LISTENING       24164
  TCP    [::]:3306              [::]:0                 LISTENING       24164
  TCP    [::]:33060             [::]:0                 LISTENING       24164
  TCP    [::1]:64861            [::1]:3306             TIME_WAIT       0

MySQL端口默认设置为3306,可通过命令检测

删除服务

C:\WindowsApplicaions\mysql-8.0.25-winx64\bin>sc delete mysql
[SC] DeleteService SUCCESS

成功删除MySQL服务后,service列表会删除MySQL服务。

修改密码

reset your password 错误提示

MySQL进入后,执行use mysql;会报错

mysql> use mysql;
No connection. Trying to reconnect...
Connection id:    14
Current database: *** NONE ***

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

reset your password 解决步骤

mysql>  alter user 'root'@'localhost' identified by '12345678';
Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> use mysql;
Database changed

退出后重新登录

mysql> exit
Bye

C:\WindowsApplicaions\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 15
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

输入密码:12345678

至此,MySQL 8.0.25 解压版,在windows中安装成功。

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