1、下载安装包
- mysql-8.0.33-winx64.zip
- https://dev.mysql.com/downloads/file/?id=518220
2、安装
-
解压 mysql-8.0.33-winx64.zip(至:C:\app\mysql-8.0.33-winx64);
-
创建my.ini文件;
默认解压目录无my.ini文件,需自己创建;
进入目录C:\app\mysql-8.0.33-winx64,创建my.ini,文件内容如下[client] port=3306 [mysql] default-character-set=utf8 [mysqld] basedir = "C:\app\mysql-8.0.33-winx64" #更改为自己的安装目录 datadir = "C:\app\mysql-8.0.33-winx64\data" #更改为自己的安装目录/data port = 3306 max_connections=200 character-set-server=utf8 default-storage-engine=INNODB
-
初始化MySQL
管理员身份打开CMD,执行如下命令cd C:\app\mysql-8.0.33-winx64\bin mysqld --initialize-insecure mysqld -install
若提示"The service already exists! The current server installed:xxx",则先删除旧服务后再执行" mysqld -install "
net stop mysql mysqld -remove mysql
-
启动MySQL
net start mysql
-
配置环境变量
添加变量: MYSQL_HOME = C:\app\mysql-8.0.33-winx64
修改Path变量,在原Path变量的值前添加:%MYSQL_HOME%\bin; -
登录MySQL
# 初始化root密码 mysqladmin -u root password 1234 # 登录MySQL mysql -u root -p # 输入 12345678 show databases;