1、官网下载App,https://dev.mysql.com/downloads/file/?id=484900
2、解压到安装目录:C:\apps\mysql-8.0.15-winx64。
3、配置环境变量:
MYSQL_HOME=C:\apps\mysql-8.0.15-winx64
PATH 添加:%MYSQL_HOME%\bin
4、进入安装目录,手动创建my.ini文件,内容如下:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=C:\apps\mysql-8.0.15-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\work_data\mysql\8.0.15
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
5、使用管理员权限进入cmd,初始化数据目录和用户名密码,加粗部分即初始密码:
mysqld --initialize --console
C:\Windows\system32>mysqld --initialize --console
2019-03-08T11:35:43.723725Z 0 [System] [MY-013169] [Server] C:\apps\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 68020
2019-03-08T11:35:43.725585Z 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.
2019-03-08T11:35:49.852928Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 3oi,8!t?qQ,t
2019-03-08T11:35:52.216503Z 0 [System] [MY-013170] [Server] C:\apps\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed
C:\Windows\system32>
6、使用管理员权限进入cmd,将MySQL安装为系统服务:
mysqld --install mysql
net start mysql