![4feb7dba040d47ce157aa72f2c0caca8.png](https://img-blog.csdnimg.cn/img_convert/4feb7dba040d47ce157aa72f2c0caca8.png)
- 原作者:千锋实践训练营
- 原出处:知乎平台
- 原文链接:千锋实践训练营:Windows版本 - MySql5.7.26压缩包版本安装流程
Windows版本 - MySql5.7.26压缩包版本安装流程
1. 下载和解压
下载地址:https://dev.mysql.com/downloads/file/?id=485477
![a62b9da55c7630bf5ddc7379e4db8fd3.png](https://img-blog.csdnimg.cn/img_convert/a62b9da55c7630bf5ddc7379e4db8fd3.png)
2. 解压后的文件
![428f61be65355629645eba6fc138756d.png](https://img-blog.csdnimg.cn/img_convert/428f61be65355629645eba6fc138756d.png)
3. 环境变量配置
第一步:拷贝路径
解压包文件夹下:bin文件夹目录拷贝全路径;
C:mysql-5.7.26-winx64bin
第二步:添加到系统Path路径中
4. 安装和配置文件
第一步:手动在bin目录中新增my.ini
![1852cf504288c521419f9144efb25f40.png](https://img-blog.csdnimg.cn/img_convert/1852cf504288c521419f9144efb25f40.png)
第二步:在mysql-5.7.26-winx64目录下创建data文件夹用于存储数据
![0d2a59f7273575704fb5da3dd4be70cc.png](https://img-blog.csdnimg.cn/img_convert/0d2a59f7273575704fb5da3dd4be70cc.png)
第三步:修改my.ini文件-如下
# MySQL配置
[mysql]
# MySQL默认字符集编码
default-character-set=utf8
[mysqld]
# MySQL端口
port=3306
# MySQL安装路径
basedir=C:mysql-5.7.26-winx64
# MySQL数据库文件路径
datadir=C:mysql-5.7.26-winx64data
# MySQL数据库默认编码
character-set-server=utf8
# 表存储引擎方式 INNODB与MyISAM两种
default-storage-engine=INNODB
# SQL验证模式
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
第四步:mysql默认密码:
第一步:用管理员身份打开cmd 命令 切换到C:mysql-5.7.26-winx64bin目录中(安装mysql的目录下bin文件)
第二步:输出默认情况下需要设置初始化密码:mysqld --initialize --user=mysql --console
可能会遇到的问题如下:如果没有请略过
![b8397e4e68664ffe8532b3046dacc2e3.png](https://img-blog.csdnimg.cn/img_convert/b8397e4e68664ffe8532b3046dacc2e3.png)
解决方式:下载vcredist_x64.exe . 地址如下:安装。
https://www.microsoft.com/en-us/download/details.aspx?id=40784
![d4769ae1406816808de3ecdbbb1548bb.png](https://img-blog.csdnimg.cn/img_convert/d4769ae1406816808de3ecdbbb1548bb.png)
![4483300a9b0d32824b36ad5f100bd37c.png](https://img-blog.csdnimg.cn/img_convert/4483300a9b0d32824b36ad5f100bd37c.png)
运行代码:(备注:一定要检查是否切换至安装目录的bin文件下,如果没有尝试写好安装盘符 :如 D :)
C:Windowssystem32>cd C:mysql-5.7.26-winx64bin
C:mysql-5.7.26-winx64bin>mysqld --initialize --user=mysql --console
2019-07-13T17:13:22.735474Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-07-13T17:13:22.996893Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-07-13T17:13:23.056920Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-07-13T17:13:23.159899Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 84fd690f-a591-11e9-86e2-000c2968b79f.
2019-07-13T17:13:23.177571Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-07-13T17:13:23.192543Z 1 [Note] A temporary password is generated for root@localhost: -KwRajl4)ljw
第四步:如果之前安装过Mysql请执行一下代码:没有的请略过
可能会遇到:之前的MySql没有卸载干净,执行一下代码
sc query mysql
sc delete mysql
C:mysql-5.7.26-winx64bin>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 : 0x0
C:mysql-5.7.26-winx64bin>sc delete mysql
[SC] DeleteService 成功
第五步:
安装成功:mysqld install
C:mysql-5.7.26-winx64bin>mysqld install
Service successfully installed.
第六步:
启动成功:net start mysql
如果不成功执行:mysqld remove并检查my.ini配置文件
C:mysql-5.7.26-winx64bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
第七步:
成功访问:mysql -uroot -p
C:mysql-5.7.26-winx64bin>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.26
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.
mysql>
第八步:
修改密码:set password for root@localhost = password('root');
mysql> set password for root@localhost = password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
第九步:退出mysql ;输入exit; 重新测试新密码登录:root
恭喜你,已经按照成功。
请忽略以下内容(如果按照不成功可以看)
忘记密码修改:
1.停止服务 net stop mysql
2.mysqld --skip-grant-tables
3.回车之后就不要动了,再新打开一个命令提示符窗口,同样进入mysql的安装目录下,
输入:mysql -u root -p
密码为空,直接回车
接着输入以下命令:
use mysql;
update user set authentication_string=password("123456") where user="root";
flush privileges;
以上三条命令执行完毕之后,打开命令提示符窗口,
输入mysql -u root -p,回车(前提是配置好了环境变量,没有配置的可以自行百度)
输入密码:123456
4.重启服务之前需在任务管理器里面把Mysql任务kill
删除数据库操作
C:Windowssystem32>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
C:Windowssystem32>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 : 0x0
C:Windowssystem32>sc delete mysql
[SC] DeleteService 成功
![9f07f2fc5ef0f6ccbfb4f33eda300e5f.png](https://img-blog.csdnimg.cn/img_convert/9f07f2fc5ef0f6ccbfb4f33eda300e5f.png)
MySQL提示Could not start the service MySQL提示
安装mysql 5.1.33,在运行Server Instance Configuration wizard时的Execute configurattion步骤中的第三项Start Service进出错,错误提示为Could not start the service MySQL
分析:这种情况一般是因为装过mysql,卸载不干净造成的,卸载后重启后再重装。注意看下服务,如果未能卸载,可以用mysqld-nt -remove卸载。