MySQL 安装记录

博客发表于:Ghamster Blog
转载请注明出处

因MySQL官方似乎未提供64-bit版本的.msi文件下载,所以只好使用.zip包安装64-bit版本。另外,从5.7.18版本开始,.zip包中不再包含样例配置文件my-default.ini(本文末尾提供my-default.ini完整代码,提取自5.7.17版本)。

下载

MySQL 官方下载地址:https://dev.mysql.com/downloads/mysql/
MySQL workbench官方下载地址:https://dev.mysql.com/downloads/workbench/

安装

本例中:

安装文件:mysql-5.7.20-winx64.zip
安装路径:D:\develop\mysql-5.7.20-winx64
密码:'new password'

解压文件

mysql-5.7.20-winx64.zip解压至D:\develop\mysql-5.7.20-winx64

修改my-default.ini并重命名为my.ini

在文件末尾添加:

basedir="D:\develop\mysql-5.7.20-winx64"
datadir="D:\develop\mysql-5.7.20-winx64\data"
character-set-server=utf8

命令行安装

添加环境变量,将解压缩的安装文件中,bin目录添加至Path
初始化数据库:

  • 以管理员权限打开cmd,切换至bin目录下(非必需,但为了减少异常,建议这么做)

  • 执行mysqld --initialize --user=mysql --console,该命令初始化数据库,生成临时密码,打印信息

  • 记录控制台信息最后一行,打印的临时密码

    log2018-02-02T05:57:23.355219Z 1 [Note] A temporary password is generated for root@localhost: Yi;z%D:fl4Ds

将mysql加入系统服务,mysqld --install mysql
启动mysql,net start mysql

登陆并修改密码

登陆

mysql -u root -p
Enter password: Yi;z%D:fl4Ds

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
flush privileges;

附件

my-default.ini文件:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

你可能感兴趣的:(MySQL 安装记录)