在官网下载压缩包,找个好地方放好,然后去配置环境变量
保存my.ini文件
[mysqld]
# 设置服务端使用的字符集为utf-8
character-set-server=utf8
# 绑定IPv4地址
bind-address = 0.0.0.0
# 设置mysql的端口号
port = 3306
# 设置mysql的安装目录(能看到bin即可)
basedir=D:\mysql-5.7.28-winx64
# 设置mysql数据库的数据的存放目录
datadir=G:\other\Mysql5.7\data
# 允许最大连接数
max_connections=2000
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 设置mysql以及数据库的默认编码
[mysql]
default-character-set=utf8
[mysql.server]
default-character-set=utf8
# 设置客户端默认字符集
[client]
default-character-set=utf8
如果datadir的地址格式错误了,比如datadir=datadir=G:\other\Mysql5.7\data
就会出现这样的问题,错误提示不太友好
D:\mysql-5.7.28-winx64\bin>mysqld --initialize --console
mysqld: Can't create/write to file 'datadir=G:\other\Mysql5.7\data\is_writable' (Errcode: 2 - No such file or directory)
2022-09-07T14:47:26.588398Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-09-07T14:47:26.590937Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting.
2022-09-07T14:47:26.591684Z 0 [ERROR] Aborting
D:\mysql-5.7.28-winx64\bin>mysqld --initialize --console
mysqld: Can't create directory 'G:\other\Mysql5.7\data\' (Errcode: 2 - No such file or directory)
2022-09-07T14:48:11.769363Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-09-07T14:48:11.772070Z 0 [ERROR] Aborting
只需要把目录地址改正确就可以了,datadir=G:\other\Mysql5.7\data
打开管理员权限的命令行进入到对应的bin目录里面执行安装,指定服务名,因为我电脑中还有MySQL8,要配很多个,所以就要命不同的名
初始化,拿到密码
在本地服务中启动MySQL,选中后启动
进入命令行配置密码