【MySQL】windows安装MySQL 5.7


如果直接安装官网的安装包(MySQL Community Server),会连带一些用不上的软件。


一、下载MySQL

清华大学开源软件镜像站:mysql-5.7.31-winx64.msi

二、安装MySQL

可以用ZIP,也可以用安装包,个人感觉安装包更容易管理。
双击安装,默认路径:C:\Program Files\MySQL\MySQL Server 5.7
安装后大约占用400MB空间,实际数据本身也会占一定空间。

开始安装
阅读协议
典型安装
执行安装
安装完成

三、添加环境变量

编辑环境变量

四、创建文件夹

安装成功后,系统会新增两个文件夹。

  • C:\Program Files\MySQL\MySQL Server 5.7
  • C:\ProgramData\MySQL\MySQL Server 5.7\data

但是data文件夹是空的(里面有三个文件夹,也是空的)。
假如data有内容,把data全部内容删除,然后用命令行初始化。

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。

PS C:\Windows\system32> cd 'C:\Program Files\MySQL\MySQL Server 5.7\bin\'
PS C:\Program Files\MySQL\MySQL Server 5.7\bin> .\mysqld.exe --initialize-insecure --user=mysql --datadir="C:\ProgramData\MySQL\MySQL Server 5.7\data"
PS C:\Program Files\MySQL\MySQL Server 5.7\bin>

五、配置文件

配置文件优先级

  1. C:\Windows\my.ini
  2. C:\Windows\my.cnf
  3. C:\my.ini
  4. C:\my.cnf
  5. C:\Program Files\MySQL\MySQL Server 5.7\my.ini
  6. C:\Program Files\MySQL\MySQL Server 5.7\my.cnf

客户端配置

路径:C:\Program Files\MySQL\MySQL Server 5.7\my.ini

[mysql]

no-beep
default-character-set=utf8

服务端配置

路径:C:\ProgramData\MySQL\MySQL Server 5.7\data\my.ini

[mysqld]

# Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.7/"

# Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.7/data/"

# The TCP/IP Port the MySQL Server will listen on
port=3306

# sql_mode
sql_mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# UTF-8
character_set_server=utf8

# innoDB
default-storage-engine=INNODB

# ***** Group Replication Related *****
# Defines the algorithm used to hash the writes extracted during a transaction. If you
# are using Group Replication, this variable must be set to XXHASH64 because the process
# of extracting the writes from a transaction is required for conflict detection on all
# group members.
# transaction_write_set_extraction
lower_case_table_names=1

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=151

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
table_open_cache=2000

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=19M

# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations n
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值