当前位置: 首页 > news >正文

Windows 离线安装 MySQL 8

目录

1. 下载离线安装包

2. 上传解压

3 配置 my.ini 文件

4 设置系统环境变量

5 安装 MySQL

6 登录 MySQL


 

客户环境是内网环境,不能访问外网,只能离线安装 MySQL 了。

1. 下载离线安装包

MySQL 离线压缩包官网下载地址:MySQL :: Download MySQL Community Server (Archived Versions)

此次安装 8.0.20 版本!

2. 上传解压

解压后的文件目录:

        可以看到,默认是没有 data 文件夹和 my.ini 文件的,则需要我们自己手动创建这两个目录和文件即可:

3 配置 my.ini 文件

[mysqld]
# 设置 3306 端口
port=3306# 设置 mysql 的安装目录,即 bin 目录
basedir="mysql 安装目录"# 设置 mysql 数据库的数据的存放目录,即 data 目录
datadir="mysql 安装目录再加上 \data"# 允许最大连接数
max_connections=200# 允许连接失败的次数
max_connect_errors=10# 服务端使用的字符集默认为 utf8
character-set-server=utf8# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB# 默认使用 “mysql_native_password” 插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password[mysql]
# 设置 mysql 客户端默认字符集
default-character-set=utf8[client]
# 设置 mysql 客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

4 设置系统环境变量

 

5 安装 MySQL

以管理员身份启动 cmd 或 PowerShell 进行以下操作:

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。PS C:\Users\Administrator> cd E:\keymanTech\dbs\mysql-8.0.20-winx64\bin
PS E:\keymanTech\dbs\mysql-8.0.20-winx64\bin> mysqld --initialize --console
2023-02-14T06:59:51.688125Z 0 [System] [MY-013169] [Server] E:\keymanTech\dbs\mysql-8.0.20-winx64\bin\mysqld.exe (mysqld 8.0.20) initializing of server in progress as process 16856
2023-02-14T06:59:51.688225Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'E:\keymanTech\dbs\mysql-8.0.20-winx6in\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-02-14T06:59:51.689181Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-02-14T06:59:51.712993Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-14T06:59:52.262250Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-14T06:59:53.741675Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: s-fqTBh.=7?e

但是在安装过程中有报错信息:

[ERROR] [MY-010338] [Server] Can't find error-message file 'E:\xxx\mysql-8.0.20-winx6in\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

解决办法:

查了很多教程最后发现是转义字符出现了问题:MySQL Bugs: #90364: Can't find error-message file

        因为我们在配置 MySQL 安装目录的时候,没有将安装目录配置到根目录下(就是 MySQL 解压文件根目录)或者没有加双斜杠:

  • 错误路径:basedir="D:\\InstalledDevsoftware\\XXX"  或 D:\InstalledDevsoftware\XXX
  • 正确路径:basedir="D:\\Devsoft\\mysql-8.0.20-winx64\\XXX"

还需要在 my.ini 多加一行内容:

······
# 设置 mysql 的安装目录,即 bin 目录
basedir="E:\\xxx\\mysql-8.0.20-winx64\\bin"# 设置 mysql 数据库的数据的存放目录,即 data 目录
datadir="E:\\xxx\\mysql-8.0.20-winx64\\data"lc-messages-dir="E:\\xxx\\mysql-8.0.20-winx64\\share\\english"
······

再次执行 mysqld --initialize --console 命令:

报另外一个错误信息: [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.

解决办法:清空 data 文件夹下的内容即可!

再次执行 mysqld --initialize --console 命令:

PS E:\keymanTech\dbs\mysql-8.0.20-winx64\bin> mysqld --initialize --console
2023-02-14T07:17:13.196681Z 0 [System] [MY-013169] [Server] E:\keymanTech\dbs\mysql-8.0.20-winx64\bin\mysqld.exe (mysqld 8.0.20) initializing of server in progress as process 19932
2023-02-14T07:17:13.196777Z 0 [Warning] [MY-010339] [Server] Using pre 5.5 semantics to load error messages from E:\keymanTech\dbs\mysql-8.0.20-winx64\share\english\. If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2023-02-14T07:17:13.197450Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-02-14T07:17:13.219796Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-14T07:17:13.717398Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-14T07:17:15.254780Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: h5(rJyMiFKn0
PS E:\keymanTech\dbs\mysql-8.0.20-winx64\bin> mysqld --install
Service successfully installed.
PS E:\keymanTech\dbs\mysql-8.0.20-winx64\bin> net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。

在任务管理器中库看到名为 MySQL 的服务:

6 登录 MySQL

用前面随机生成的密码登录:

PS E:\xxx\mysql-8.0.20-winx64\bin> mysql -u root -p
Enter password: ************# 修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';# 用新密码登录
PS E:\xxx\mysql-8.0.20-winx64\bin> mysql -u root -p
Enter password: **********

至此 MySQL 8 安装成功!!!

http://www.lryc.cn/news/7024.html

相关文章:

  • 【前端攻城狮之vue基础】02路由+嵌套路由+路由query/params传参+路由props配置+replace属性+编程式路由导航+缓存路由组件
  • CHAPTER 1 Zabbix介绍及安装
  • 认识V模型、W模型、H模型
  • excel ttest检测
  • PDFPrinting.Net操作进行细粒度控制
  • SegPGD
  • ESP-IDF + Vscode ESP32 开发环境搭建以及开发入门
  • SpringMvc的请求和响应
  • 【Vue3】首页主体-面板组件封装
  • 部署 K8s 集群
  • 关于北京君正:带ANC的2K网络摄像头用户案例
  • ccc-Backpropagation-李宏毅(7)
  • 找出字符串中第一个匹配项的下标-力扣28-java
  • SpringBoot 监听Redis key过期回调
  • 蓝桥杯C/C++VIP试题每日一练之回形取数
  • 四控、三管、一协调
  • jdk19下载与安装教程(win10)超详细
  • 来来来,手摸手写一个hook
  • 【C++】AVL树
  • Mybatis源码(2) - SqlSessionTemplate的介绍及创建过程
  • 女生做大数据有发展前景吗?
  • Git实用指令记录
  • 复杂美公链技术重要特色:平行公链架构
  • Java——进制转换的一些内容
  • 使用 Nodejs、Express、Postgres、Docker 在 JavaScript 中构建 CRUD Rest API
  • 电子招标采购系统源码之什么是电子招投标系统?
  • 匹配文件名称模块glob和fnmatch
  • day12_oop
  • 在 Flutter 中使用 webview_flutter 4.0 | js 交互
  • 嵌入式ARM工业边缘计算机BL302的CAN总线接口如何设置?