MySQL5.7.28 Windows X64 (ZIP decompression version) Installation Guide

1. Download mysql 5.7.28 (win64) archive

    Official website download page, https: //dev.mysql.com/downloads/mysql/5.7.html

    

2. Prepare mysql-home catalog

    New mysql folder in the root directory C,

        The compressed package such as bin mysql folder to folder here.    

    bin: executable commands, such as mysql, mysqld and so on.

    docs: mysql stored documents.

    include: comprising (header) file, mysql external API interfaces, e.g. mysql.h;

    lib: used to store a series of libraries;

    share: the character set used to store information, such as language;

 

3. With the environment variable with Path

    Increase system environment variables MYSQL_HOME = C: \ mysql

    Edit the system environment variables Path, appending;% MYSQL_HOME% \ bin

    

4. Configuration and configuration explained my.ini

    Create a txt file, rename my.ini, open and edit, fill in the content.

    Save as selected encoded as ANSI.

  >>>>>>>>

    [client]

    port = 3306

    default-character-set = utf8mb4

 

    [mysql]

    default-character-set = utf8mb4

 

    [mysqld]

    basedir = C:\mysql

    datadir = C:\mysql\data

    port = 3306

    character-set-client-handshake = FALSE

    character-set-server = utf8mb4

    collation-server = utf8mb4_unicode_ci

    init_connect = 'SET NAMES utf8mb4'

    sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

  <<<<<<<<  

  basedir:当前MySQL存放地址,与mysql_home环境变量的值一致。

  datadir:数据库存放地址,可指定数据库内容存放目录,推荐在mysql_home下。

  port:MySQL服务的监听端口。

  配置文件中缺省了端口的使用规则,使用了默认规则。

 

  utf8mb4:在5.5.3以前使用'utf8',在5.5.3以后使用utf8mb4,

    它兼容utf8,解决了移动端的表情或者一些4字节emoji存不进数据库的问题。

5.初始化mysql基本库

    以管理员运行CMD

    mysqld --initialize --user=mysql --console

    命令行root@localhost后的随机字符串就是root的临时密码。

    注意:每次初始化请先清空data文件夹。

6.注册安装成为mysql服务

mysqld install MySQL --defaults-file="C:\my.ini"

启动时手动指定配置文件。

补充:  windows 版本的MySQL 默认首先读取C盘跟目录下的my.ini文件,

然后是my.cnf,

最后在%WINDIR%中找my.ini或my.cnf

    

 

7.启动停止mysql

    启动命令: net start MySQL

    停止命令: net stop MySQL

    若提示,正在启动或停止中请稍后片刻再试一次,使用命令强杀。

    强杀进程:taskkill /f /t /im mysqld.exe

排查启动错误:mysqld –console

 

8.修改root密码

    mysql -u root -p

    提示你输入密码,将第五步的临时密码输入。

    SET PASSWORD = PASSWORD('你的新密码');

    

9.允许外部访问

        GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'  IDENTIFIED BY '你设置的密码'  WITH GRANT OPTION;

        flush privileges;

 

10.配置防火墙入站规则

Windows防火墙-》高级设置-》入站规则-》新建规则-》端口-》TCP特定本地端口-》允许连接-》全选-》自定义规则名-》完成

发布了96 篇原创文章 · 获赞 172 · 访问量 25万+

Guess you like

Origin blog.csdn.net/ai_64/article/details/103464262