1.下载解压
    下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.14-winx64.zip
    将下载的mysql解压重命名放在C:\Program Files\MySQL\MySQL Server 5.7”
    2.创建目录
    创建数据文件和日志文件存放目录:D:\MySQL\Data;D:\MySQL\Log
    3.创建my.ini
    在C盘根目录下创建my.ini文件(注意隐藏的文件后缀名),内容如下(只列出安装的一些需要的配置):
    复制代码

    1. [client]
    2. no-beep
    3. socket =0.0
    4. port=3306
    5. [mysqld]
    6. server-id=45
    7. port=3306
    8. character-set-server=utf8mb4
    9. pid-file ="mysql.pid"
    10. socket =0.0
    11. basedir="C:\Program Files\MySQL\MySQL Server 5.7"
    12. datadir="D:\MySQL\Data"
    13. tmpdir="D:\MySQL\Data"
    14. default-storage-engine=INNODB
    15. slow-query-log=1
    16. long_query_time=1
    17. slow_query_log_file="D:\MySQL\Log\mysql-slow.log"
    18. ##log-bin="D:\MySQL\Log\mysql-bin"
    19. log-error="D:\MySQL\Log\mysql-error.log"

    4.初始化安装
    进入cmd命令界面

    1. cd C:\Program Files\MySQL\MySQL Server 5.7\bin
    2. mysqld --defaults-file="C:\my.ini" --initialize --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp

    5.配置环境变量
    在环境变量中加入

    1. C:\Program Files\MySQL\MySQL Server 5.7\bin

    6.添加mysql服务
    增加服务

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

    移除服务

    1. mysqld remove

    注意:这里的“MySQL”是设的服务名

    7.启动关闭mysql

    1. net start mysql
    2. net stop mysql

    8.登入mysql
    1.如果安装方式使用的是-initialize-insecure,在安装的过程中会生成一个root用户密码
    2.如果使用—initialize方式安装,在在错误日志文件中会生成一个root用户密码(我这里就是采取第二种安装方法)

    9.修改用户密码

    1. SET password=PASSWORD('');
    2. ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

    参考:http://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html

    错误解决
    最近在英文版的windows2008r2上面安装mysql5.7,使用—initialize方式安装,最后使用error中生产的初始root密码登入提示错误“ERROR 1130 (HY000): Host ‘::1’ is not allowed to connect to this MySQL server”;一直没办法识别mysql.user中host列中的localhost登入方式。解决办法:
    办法1:
    复制代码
    1.在my.ini中加上skip-grant-tables
    2.重启mysql服务
    3.登入mysql,随便输入一个错误的密码
    4.update mysql.user set host=’%’ where user=’root’;将root的登入方式改成‘%’
    5.去除my.ini中的skip-grant-tables
    6.使用错误日志中给出的临时root密码登入mysql
    7.修改root密码
    复制代码
    办法2:
    修改hosts文件加入当前服务器ip对应localhost的记录