博客發(fā)表于:Ghamster Blog
轉(zhuǎn)載請注明出處
因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
命令行安裝
添加環(huán)境變量露氮,將解壓縮的安裝文件中,bin
目錄添加至Path
初始化數(shù)據(jù)庫:
以管理員權(quán)限打開
cmd
钟沛,切換至bin
目錄下(非必需畔规,但為了減少異常,建議這么做)執(zhí)行
mysqld --initialize --user=mysql --console
恨统,該命令初始化數(shù)據(jù)庫叁扫,生成臨時密碼,打印信息-
記錄控制臺信息最后一行畜埋,打印的臨時密碼
log2018-02-02T05:57:23.355219Z 1 [Note] A temporary password is generated for root@localhost: Yi;z%D:fl4Ds
將mysql加入系統(tǒng)服務(wù)莫绣,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