【MySQL】windows安装MySQL 5.6
如果直接安装官网的安装包(MySQL Community Server),会连带一些用不上的软件。
一、下载MySQL
搜狐镜像站:mysql-5.6.39-winx64.msi
二、安装MySQL
可以用ZIP,也可以用安装包,个人感觉安装包更容易管理。
双击安装,默认路径:C:\Program Files\MySQL\MySQL Server 5.6
安装后大约占用353MB空间,实际数据本身也会占一定空间。
三、添加环境变量
四、检查文件夹
安装成功后,系统会新增两个文件夹。
- C:\Program Files\MySQL\MySQL Server 5.6
- C:\ProgramData\MySQL\MySQL Server 5.6\data
五、配置文件
配置文件优先级
- C:\Windows\my.ini
- C:\Windows\my.cnf
- C:\my.ini
- C:\my.cnf
- C:\Program Files\MySQL\MySQL Server 5.6\my.ini
- C:\Program Files\MySQL\MySQL Server 5.6\my.cnf
客户端配置
[mysql]
no-beep
default-character-set=utf8
服务端配置
[mysqld]
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe
# shared-memory
# shared-memory-base-name=MYSQL
# The Pipe the MySQL Server will use
# socket=MYSQL
# The TCP/IP Port the MySQL Server will listen on
port=3306
# Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.6/"
# Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.6/data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
# Binary Logging.
# log-bin
# 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
# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=0
# 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=240M
# 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 needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=10
#*** MyISAM Specific options
# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G
# If the temporary file used for fast index creation would be bigger
# tha