1.下载安装包
# 本文版本:mysql-8.0.20-winx64.zip
2.解压到安装目录
# 本机安装目录:D:\program\mysql8020\mysql-8.0.20-winx64
# 创建数据目录:D:\program\mysql8020\sqldata
3.新建配置文件
## 在安装目录创建my.ini文件,内容如下:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\program\mysql8020\mysql-8.0.20-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\program\mysql8020\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
4.管理员权限进入cmd
## 执行如下命令:
C:\WINDOWS\system32>cd /d D:\program\mysql8020\mysql-8.0.20-winx64\bin
D:\program\mysql8020\mysql-8.0.20-winx64\bin>mysqld install
Service successfully installed.
D:\program\mysql8020\mysql-8.0.20-winx64\bin>mysqld --initialize-insecure
D:\program\mysql8020\mysql-8.0.20-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
D:\program\mysql8020\mysql-8.0.20-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.20 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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 with mysql_native_password by 'ly447742';
Query OK, 0 rows affected (0.08 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)