Mysql 5.7版本为跨度比较大的一个版本,安装配置较之前版本有些不同
以下版本为Mysql 5.7.13
1. 从Mysql官网下载Mysql,解压至任意目录
2. 在根目录下新建my.ini,粘贴以下内容
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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.
[client]
default-character-set=utf8
[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 = D:\Program Files (x86)\MySQL 5.7.13
datadir = D:\Program Files (x86)\MySQL 5.7.13\data
port = 3306
character-set-server = utf8
default-storage-engine = INNODB
log-error=D:\Program Files (x86)\MySQL 5.7.13\data\mysql_error.log
# 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.
max_connections = 100
table_open_cache = 256
query_cache_size = 1M
tmp_table_size = 32M
thread_cache_size = 8
innodb_data_home_dir = "D:\Program Files (x86)\MySQL 5.7.13\data"
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 128M
innodb_buffer_pool_size = 128M
innodb_log_file_size = 10M
innodb_thread_concurrency = 16
innodb-autoextend-increment = 1000
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
max_allowed_packet = 32M
explicit_defaults_for_timestamp=true
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
3.修改环境变量
在path中添加 %MYSQL_HOME%\bin;
%MYSQL_HOME%为mysql解压目录。
4.初始化data目录
mysqld --initialize-insecure
5.6版本以前自带Data目录,不需要这一步。而5.7版本如果没有这一步会无法启动mysql服务。
mysqld –initialize-insecure 自动生成无密码的root用户。
mysqld –initialize 是自动生成随机密码用户。
5.注册Mysql服务
mysqld --install MySQL --defaults-file="%MYSQLHOME%\my.ini"
移除安装:mysqld remove;
6.启动Mysql服务
net start mysql
关闭服务:net stop mysql
7.修改root账号的密码
mysql -u root -p
SET PASSWORD = PASSWORD('你的新密码');
在 Mysql 5.7.13 中, 系统的 user 表中没有 password 这一列了, 所以Mysql 5.6.* 直接用 update 语句来更新root密码的方法不可用了, 我们只能用 SET PASSWORD = PASSWORD(‘你的新密码’); 来修改密码。
修改完密码之后, 需要重启 MySQL 服务才生效。