• MySQL8.0.28在Win10下安装


    MySQL8.0.28在Win10下安装

    需要在Windows下安装一个MySQL用,原来以为MySQL在win10下安装就是,setup,然后一路next就可以,没有想到比Linux还麻烦 。

    1、下载软件

    到官网上下载,不要下载debug的版本。
    在这里插入图片描述
    没有安装文件,就是一个应用程序文件夹。

    2、配置路径和环境

    (1)配置路径

    把解压缩的文件都拷贝到这个路径下

    D:\app\mysql-8.0.28-winx64
    
    • 1

    在系统属性中,设置环境变量
    在这里插入图片描述
    在系统环境变量设置中,增加路径,D:\app\mysql-8.0.28-winx64\bin
    在这里插入图片描述

    (2)数据路径和配置文件

    在D:\app\mysql-8.0.28-winx64\,增加一个数据库文件的路径

    D:\app\mysql-8.0.28-winx64\Data
    
    • 1

    在D:\app\mysql-8.0.28-winx64\,编辑一个启动配置文件 my.ini
    注意:basedir 、datadir 需要根据实际路径调整

    [mysqld]
    #设置3306端口
    port=3306
    #设置mysql的安装目录
    basedir="D:\\app\\mysql-8.0.28-winx64"
    #设置mysql数据库的数据的存放目录
    datadir="D:\\app\\mysql-8.0.28-winx64\\data"
    #允许最大连接数
    max_connections=200
    #允许连接失败的次数。
    max_connect_errors=10
    #服务端使用的字符集默认为utf8mb4
    character-set-server=utf8mb4
    #创建新表时将使用的默认存储引擎
    default-storage-engine=INNODB
    #默认使用“mysql_native_password”插件认证
    #mysql_native_password
    default_authentication_plugin=mysql_native_password
    [mysql]
    #设置mysql客户端默认字符集
    default-character-set=utf8mb4
    [client]
    #设置mysql客户端连接服务端时默认使用的端口
    port=3306
    default-character-set=utf8mb4
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    3、数据库服务初始化和启动

    (1)初始化
    D:\app\mysql-8.0.28-winx64\bin>mysqld --initialize --console
    
    
    • 1
    • 2

    windows弹窗”由于找不到VCRUNTIME 140_1.dll,无法继续执行代码.重新安装程序可能会解决此问题.“
    原因是没有VC++环境,需要下载安装VC_redist.x64 ,默认安装即可。下载地址如下。

    https://learn.microsoft.com/zh-CN/cpp/windows/latest-supported-vc-redist?view=msvc-170
    
    • 1

    安装后重启计算机,再次初始化。

    D:\app\mysql-8.0.28-winx64\bin>mysqld --initialize --console
    2022-11-12T09:27:45.591466Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
    2022-11-12T09:27:45.591492Z 0 [System] [MY-013169] [Server] D:\app\mysql-8.0.28-winx64\bin\mysqld.exe (mysqld 8.0.28) initializing of server in progress as process 5900
    2022-11-12T09:27:45.622945Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2022-11-12T09:27:45.961821Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2022-11-12T09:27:47.540761Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: _a9_bSu*gzp<
    
    D:\app\mysql-8.0.28-winx64\bin>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    初始化成功。临时密码的位置:
    临时密码:temporary password is generated for root@localhost: _a9_bSu*gzp<

    (2)配置MySQL服务

    在cmd下执行。
    mysqld --install mysql8028
    mysql8028服务名,可以自定义。

    D:\app\mysql-8.0.28-winx64>mysqld --install mysql8028
    Install/Remove of the Service Denied!
    
    • 1
    • 2

    报错,没有权限。
    用管理员执行cmd
    在这里插入图片描述
    再次执行:

    C:\Windows\system32>mysqld --install mysql8028
    Service successfully installed.
    
    
    • 1
    • 2
    • 3
    (3)登录数据库
    
    C:\Windows\system32>mysql -uroot -p
    ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)
    
    • 1
    • 2
    • 3

    在服务管理中启动服务
    在这里插入图片描述
    再次登录,修改root的密码。
    alter user ‘root’@‘localhost’ identified by ‘Mysql#8028’;

    C:\Windows\system32>mysql -uroot -p
    Enter password: ************
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 10
    Server version: 8.0.28
    
    Copyright (c) 2000, 2022, 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> alter user 'root'@'localhost' identified by 'Mysql#8028';
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql>
    mysql>
    mysql> quit
    Bye
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    验证root密码

    C:\Windows\system32>mysql -uroot -pMysql#8028
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 11
    Server version: 8.0.28 MySQL Community Server - GPL
    
    Copyright (c) 2000, 2022, 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> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.02 sec)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    安装完毕。

  • 相关阅读:
    1.OpenResty系列之入门简介
    【论文阅读】DiffusionDet: Diffusion Model for Object Detection
    Arrays 中的 asList()方法
    MySql数据库的初步安装与管理
    PdfSharp 对中文字体显示乱码的问题
    JVM-五大区
    postgres 源码解析34 进程间通信--2
    arm linux使用 usbmon 抓取usb总线数据包
    智能宠物喂食器方案软硬件设计
    2023年之我拿起“java“ java基础进阶2
  • 原文地址:https://blog.csdn.net/qq_39065491/article/details/127823218