源码家园

MySQL下载安装MySQL 9.0.1

发布日期:2024-08-20 作者:svygh123 分类:database
从0开始下载MySQL 9.0.1详细介绍安装过程

1.下载

从 https://dev.mysql.com/downloads/mysql/ 下载 mysql-9.0.1-winx64.zip

2.解压

mysql-9.0.1-winx64

3.编写配置文件my.ini(在mysql-9.0.1-winx64目录下)

[client]
port = 3306

[mysqld]
# 指定数据目录
datadir = D:/mysql-9.0.1-winx64/data
# 指定 MySQL 的端口
port = 3306
# 启用日志
log-error = D:/mysql-9.0.1-winx64/data/mysqld.log
# 指定 MySQL 的最大连接数
max_connections = 200
# 启用二进制日志
log-bin = mysql-bin
# 设置服务器 ID
server-id = 1
# 设置字符集
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

4.安装

cd进入mysql的bin目录下,执行以下语句

mysqld --initialize-insecure --user=mysql

5.安装服务(可以不安装,需要自动启动则)

mysqld install MySQL9 --defaults-file="D:/soft/mysql-9.0.1-winx64/my.ini"

启动

net start MySQL9

关闭

net stop MySQL9

移除服务

sc delete MySQL9

或者

mysqld remove mysql(这个命令需要在mysql的bin目录下)

6.不安装服务启动方式

进入mysql的bin目录

mysqld --console

提示错误1:

2024-08-20T09:30:29.816185Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2024-08-20T09:30:30.081386Z 0 [System] [MY-010116] [Server] D:mysql-9.0.1-winx64binmysqld.exe (mysqld 9.0.1) starting as process 5884
2024-08-20T09:30:30.096984Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-08-20T09:30:30.128185Z 1 [ERROR] [MY-012611] [InnoDB] Operating system error number 2 in a file operation.
2024-08-20T09:30:30.128187Z 1 [ERROR] [MY-012646] [InnoDB] File .ibdata1: 'open' returned OS error 71. Cannot continue operation
2024-08-20T09:30:30.128188Z 1 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.

网上找了,在my.ini加入以下配置

# 指定 InnoDB 数据文件
innodb_data_home_dir=D:/mysql-9.0.1-winx64/data1
innodb-data-file-path=ibdata1:10M:autoextend

继续报不一样的错:

D:mysql-9.0.1-winx64bin>mysqld --console
2024-08-20T10:05:39.172951Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2024-08-20T10:05:39.370356Z 0 [System] [MY-010116] [Server] D:mysql-9.0.1-winx64binmysqld.exe (mysqld 9.0.1) starting as process 7388
2024-08-20T10:05:39.381354Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-08-20T10:05:39.404956Z 1 [ERROR] [MY-012263] [InnoDB] The Auto-extending innodb_system data file 'D:mysql-9.0.1-winx64data1ibdata1' is of a different size 0 pages (rounded down to MB) than specified in the .cnf file: initial 640 pages, max 0 (relevant if non-zero) pages!
2024-08-20T10:05:39.404957Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
2024-08-20T10:05:39.451755Z 1 [ERROR] [MY-010334] [Server] Failed to initializeDD Storage Engine
2024-08-20T10:05:39.451756Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2024-08-20T10:05:39.451757Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-08-20T10:05:39.451767Z 0 [System] [MY-010910] [Server] D:mysql-9.0.1-winx64binmysqld.exe: Shutdown complete (mysqld 9.0.1)  MySQL Community Server
- GPL.
2024-08-20T10:05:39.451768Z 0 [System] [MY-015016] [Server] MySQL Server - end.

重新安装即可

7.修改密码

启动后,执行以下语句

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
EXIT;

您可能感兴趣的文章

联系我:357228560@qq.com
Zoomed Image