1. 下载mysql压缩包
2. 解压到指定目录,例如D:Program Filesmysql-5.7.25-winx64
3. 在目录下创建配置文件my.ini
[mysqld] port = 3306 basedir=D:/Program Files/mysql-5.7.25-winx64 datadir=D:/Program Files/mysql-5.7.25-winx64/data max_connections=200 character-set-server=utf8 default-storage-engine=INNODB sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set=utf8
4. 安装命令
D:Program Filesmysql-5.7.25-winx64in>mysqld -install
Service successfully installed.//安装成功
5. 初始化命令
D:Program Filesmysql-5.7.25-winx64in>mysqld --initialize-insecure --user=mysql
成功没有提示,失败有相应提示。
6. 启动命令
D:Program Filesmysql-5.7.25-winx64in>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
7. 修改密码
D:Program Filesmysql-5.7.25-winx64in>mysqladmin -u root -p password 123456 //123456就是设置的密码 Enter password: //由于默认没有密码,直接回车即可
8. 一个典型的问题
在执行步骤4的时候,提示已经安装
D:Program Filesmysql-5.7.25-winx64in>mysqld -install
The service already exists! The current server installed: "D:Program Filesmysql-5.7.23-winx64inmysqld" MySQL
此时需要执行以下命令:
8.1 确认Mysql服务是否已经注册
D:Program Filesmysql-5.7.25-winx64in>sc query mysql
SERVICE_NAME: mysql TYPE : 10 WIN32_OWN_PROCESS STATE : 1 STOPPED WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x7d0
8.2 删除注册服务
D:Program Filesmysql-5.7.25-winx64in>sc delete mysql
[SC] DeleteService 成功
可以重新安装了mysqld -install