这里是文章模块栏目内容页
5分钟在windows10上安装mysql8 版本

1、下载 MySQL#

https://dev.mysql.com/downloads/mysql/
image.png
image.png
下载完成后,解压缩到你的目录里。

2、配置 MySQL 的配置文件#

创建一个文件,名称为:my.ini,使用记事本打开,输入以下内容

[client]# 设置mysql客户端默认字符集default-character-set=utf8
 
[mysqld]# 设置3306端口port = 3306# 设置mysql的安装目录basedir=D:\SoftWare\Local\Work\mysql-8.0.29-winx64# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错# datadir=C:\\web\\sqldata# 允许最大连接数max_connections=20# 服务端使用的字符集默认为8比特编码的latin1字符集character-set-server=utf8# 创建新表时将使用的默认存储引擎default-storage-engine=INNODB

3、初始化数据库#

使用管理员权限打开 cmd,来到 mysql 安装目录下的 bin 目录里:
输入命令:mysqld --initialize --console

D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>mysqld --initialize --console
2022-07-06T08:38:31.781340Z 0 [System] [MY-013169] [Server] D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin\mysqld.exe (mysqld 8.0.29) initializing of server in progress as process 18088
2022-07-06T08:38:31.796289Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-06T08:38:32.132148Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-06T08:38:33.130450Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pn!gQVVuk8(a

pn!gQVVuk8(a就是默认生成的密码。

4、安装 mysqld#

输入命令:mysqld install

D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>mysqld install
Service successfully installed.

5、启动 mysql#

输入命令:net start mysql

D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

6、登录 mysql#

输入命令:mysql -u root -p
再输入刚刚mysql默认生成的密码** **pn!gQVVuk8(a

D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29

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 'root';
Query OK, 0 rows affected (0.01 sec)

mysql>

7、修改密码#

mysql8+修改密码命令: 

ALTER user 'root'@'localhost'  IDENTIFIED BY '123456';