下载
安装
-
解压到需要安装的位置
-
配置环境变量
-
配置
MYSQL_HOME
-
变量名:
MYSQL_HOME
-
变量值:MySQL 的安装目录
-
-
编辑
Path
-
新增一条变量:
%MYSQL_HOME%\bin
-
-
-
在解压后的目录创建文件
my.ini
,编辑文件[mysqld] port = 3306 # 端口号 basedir=C:/DevelopSoft/mysql5.7.26 # MySQL 安装目录 datadir=C:/DevelopSoft/mysql5.7.26/data # MySQL 安装目录下的 data,默认没有该目录,不需要创建 max_connections=6000 # 最大连接时间 character-set-server=utf8 # 编码格式 default-storage-engine=INNODB # 默认引擎 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set=utf8
-
安装 MySQL,使用管理员身份运行命令行
mysqld -install MySQL
执行成功后提示 Service successfully installed
,这时候就可以在进程服务中找到 MySQL 服务了。
-
初始化 MySQL
mysqld --initialize-insecure (密码为空) 或者 mysqld –initialize(随机生成密码)
-
运行 MySQL 服务
net start mysql(刚刚创建的服务名)
-
测试 MySQL 状态
mysql -u root -p
-
设置 MySQL 密码
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('你的新密码');
验证
C:\Users\Yuu>mysql -uroot -p
Enter password: ******
# 输出
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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.