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

基于windows安装MySQL8.0.40

基于windows安装MySQL8.0.40

基于windows 安装 MySQL8.0.40,解压文件到D:\mysql-8.0.40-winx64

在D:\mysql-8.0.40-winx64目录下创建my.ini文件,并更新一下内容

[client]    #客户端设置,即客户端默认的连接参数
# 设置mysql客户端连接服务端时默认使用的端口
port=3380#默认编码
default-character-set = utf8mb4[mysql]    #客户端设置
#MySQL 提示符配置
#用户名@主机名+mysql版本号+数据库名
prompt=\\u@\\h \\v [\\d]>\\_# 设置mysql客户端默认字符集
default-character-set = utf8mb4[mysqld]    #服务端基本设置
# 默认连接端口
port=3380# MySQL安装根目录的路径
basedir=D:\mysql-8.0.40-winx64# MySQL服务器数据目录的路径
datadir=D:\mysql-8.0.40-winx64\data# 允许最大连接数
max_connections=200# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10#服务端默认编码
character_set_server = utf8mb4#在创建新表时将使用的默认存储引擎
default-storage-engine=INNODB# 配置时区
default-time_zone='+8:00'
log_timestamps=system
D:\mysql-8.0.40-winx64\bin>mysqld --install "MySQL8" --defaults-file="D:\mysql-8.0.40-winx64\my.ini"
Service successfully installed.D:\mysql-8.0.40-winx64\bin>mysqld --initialize --console
2025-05-05T00:08:04.457934Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.40-winx64\bin\mysqld.exe (mysqld 8.0.40) initializing of server in progress as process 19256
2025-05-05T00:08:04.553388Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-05-05T00:08:14.305429Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-05-05T00:08:30.185901Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #y%7*wTmus;,D:\mysql-8.0.40-winx64\bin>net start mysql8
MySQL8 服务正在启动 ...
MySQL8 服务已经启动成功。D:\mysql-8.0.40-winx64\bin>

修改默认密码

D:\mysql-8.0.40-winx64\bin>mysql -uroot -p -P3380
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.40Copyright (c) 2000, 2024, 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.root@localhost 8.0.40 [(none)]> use mysql;
No connection. Trying to reconnect...
Connection id:    10
Current database: *** NONE ***ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
root@localhost 8.0.40 [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.07 sec)root@localhost 8.0.40 [(none)]> flush privileges;
Query OK, 0 rows affected (0.03 sec)root@localhost 8.0.40 [(none)]>

测试验证:锁定用户对于已经建立的连接无影响。

test01用户未锁定之前登录数据库并执行操作

D:\mysql-8.0.40-winx64\bin>mysql -utest01 -ptest01 -P3380
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 21
Server version: 8.0.40 MySQL Community Server - GPLCopyright (c) 2000, 2024, 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.test01@localhost 8.0.40 [(none)]> use mysql;
Database changed
test01@localhost 8.0.40 [mysql]> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
| test01           | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)

接下来锁定用户

alter user 'test01'@'localhost'  account lock;

再尝试原来的窗口执行命令,正常执行

test01@localhost 8.0.40 [mysql]> select user,host,account_lock from user;
ERROR 1054 (42S22): Unknown column 'account_lock' in 'field list'
test01@localhost 8.0.40 [mysql]> select user,host,account_locked from user;
+------------------+-----------+----------------+
| user             | host      | account_locked |
+------------------+-----------+----------------+
| mysql.infoschema | localhost | Y              |
| mysql.session    | localhost | Y              |
| mysql.sys        | localhost | Y              |
| root             | localhost | N              |
| test01           | localhost | Y              |
+------------------+-----------+----------------+
5 rows in set (0.00 sec)test01@localhost 8.0.40 [mysql]> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
| test01           | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)test01@localhost 8.0.40 [mysql]>

尝试创建新的连接,失败,提示

ERROR 3118 (HY000): Access denied for user 'test01'@'localhost'. Account is locked.

在这里插入图片描述
同理,设置密码过期对已经建立的连接无影响。

test01@localhost 8.0.40 [mysql]> select user,host,account_lock from user;
ERROR 1054 (42S22): Unknown column 'account_lock' in 'field list'
test01@localhost 8.0.40 [mysql]> select user,host,account_locked,password_expired from user;
+------------------+-----------+----------------+------------------+
| user             | host      | account_locked | password_expired |
+------------------+-----------+----------------+------------------+
| mysql.infoschema | localhost | Y              | N                |
| mysql.session    | localhost | Y              | N                |
| mysql.sys        | localhost | Y              | N                |
| root             | localhost | N              | N                |
| test01           | localhost | N              | **Y**                |
+------------------+-----------+----------------+------------------+
5 rows in set (0.00 sec)test01@localhost 8.0.40 [mysql]> select user,host,account_lock from user;
ERROR 1054 (42S22): Unknown column 'account_lock' in 'field list'
test01@localhost 8.0.40 [mysql]> select user,host,account_locked from user;
+------------------+-----------+----------------+
| user             | host      | account_locked |
+------------------+-----------+----------------+
| mysql.infoschema | localhost | Y              |
| mysql.session    | localhost | Y              |
| mysql.sys        | localhost | Y              |
| root             | localhost | N              |
| test01           | localhost | N              |
+------------------+-----------+----------------+
5 rows in set (0.00 sec)

刚开始配置my.ini文件中,没有指定时区,查看err日志文件的时候发现时间是UTC,为了方便查看日志,建议增加参数

在这里插入图片描述
增加参数后时间显示,方便阅读。
在这里插入图片描述

http://www.xdnf.cn/news/3983.html

相关文章:

  • 2025 年最新树莓派 Pico 连接 ESP8266 模块实现 WiFi 通信、搭建 TCP 服务器实现数据交互详细教程
  • 【多线程】九、常见的锁 读者写者问题
  • 「Mac畅玩AIGC与多模态19」开发篇15 - 判断节点与工具节点联动示例
  • 【爬虫】微博热搜机
  • 网络原理 TCP/IP
  • 代码异味(Code Smell)识别与重构指南
  • [网安工具] 浏览器站点指纹识别插件 —— Wappalyzer · 使用手册
  • R004 -计算机硬件基础
  • 每日c/c++题 备战蓝桥杯(P1886 滑动窗口 /【模板】单调队列)
  • 使用Prometheus监控网站是否正常打开
  • Matlab实现基于CNN-GRU的锂电池SOH估计
  • 嵌入式学习笔记 - STM32 SRAM控制器FSMC
  • 从围棋到LabVIEW:快速入门与长期精通
  • Nacos源码—3.Nacos集群高可用分析二
  • Redis从入门到实战——实战篇(下)
  • Linux的时间同步服务器(附加详细实验案例)
  • 三十一、基于HMM的词性标注
  • 相同IP和端口的服务器ssh连接时出现异常
  • 【SaaS多租架构】数据隔离与性能平衡
  • chili3d笔记11 连接yolo python http.server 跨域请求 flask
  • Linux中web服务器的部署及优化
  • 使用OpenCV 和 Dlib 实现疲劳检测
  • 【macOS常用快捷键】
  • Flink流水线任务在线演示
  • C++类和对象之默认成员函数
  • 基于 Spark 和 Hadoop 的空气质量数据分析与预测系统
  • 【AI提示词】AARRR 模型执行者
  • Google-chrome版本升级后sogou输入法不工作了
  • Cisco NDO - Nexus Dashboard Orchestrator
  • 202533 | SpringBoot集成RocketMQ