Erlo

win10安装mysql8

2025-04-14 11:30:41 发布   50 浏览  
页面报错/反馈
收藏 点赞

win10安装mysql8

一、下载

从官网(传送门)下载zip文件放在安装位置,我放在D盘根目录了

地址: https://downloads.mysql.com/archives/community/

下载好之后解压,我的位置在 D:mysql-8.0.34-winx64

二、修改配置

进入解压文件之后创建 my.ini文件 内容如下:

需要修改的位置basedir和datadir

datadir:数据库的数据的存放目录 我在安装目录创建了一个data,有其他需求的自己改

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:mysql-8.0.34-winx64 
# 设置mysql数据库的数据的存放目录
datadir=D:mysql-8.0.34-winx64data  
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

三、安装

管理员身份运行cmd

然后进入mysql安装目录下的bin文件夹(D:mysql-8.0.34-winx64bin)

1、输入:mysqld --initialize --console 命令初始化mysql

如果配置环境变量就没必要进入到bin目录了

C:WINDOWSsystem32>D:

D:>cd D:mysql-8.0.34-winx64bin

D:mysql-8.0.34-winx64bin>mysqld --initialize --console
2023-10-24T02:24:46.512711Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2023-10-24T02:24:46.512743Z 0 [System] [MY-013169] [Server] D:mysql-8.0.34-winx64binmysqld.exe (mysqld 8.0.34) initializing of server in progress as process 9292
2023-10-24T02:24:46.514743Z 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-10-24T02:24:46.659221Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-24T02:24:54.829085Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-10-24T02:25:01.378161Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Qpf&Hqo2AwuY
2023-10-24T02:25:02.299377Z 6 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

D:mysql-8.0.34-winx64bin>

执行完 mysqld --initialize --console 命令后稍等一会 就会出现一个临时密码 Qpf&Hqo2AwuY(备份一下,一会修改密码需要用的一下)

[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Qpf&Hqo2AwuY

2、安装mysql服务

输入:mysqld  --install   命令

D:mysql-8.0.34-winx64bin>mysqld  --install
Service successfully installed.

3、启动MySQL服务

输入:net start mysql   命令

D:mysql-8.0.34-winx64bin>net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。

4、进入mysql

输入:mysql -u root -p 命令,然后在输入刚刚生成的临时密码


D:mysql-8.0.34-winx64bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 12
Server version: 8.0.34

Copyright (c) 2000, 2023, 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>

5、修改密码

输入:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';


mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.15 sec)

mysql>

到这安装就结束了

记得配置一下环境变量!

登录查看全部

参与评论

评论留言

还没有评论留言,赶紧来抢楼吧~~

手机查看

返回顶部

给这篇文章打个标签吧~

棒极了 糟糕透顶 好文章 PHP JAVA JS 小程序 Python SEO MySql 确认