解压版 mysql 安装教程

本文只针对解压版 mysql,windows 下的 msi 安装文件除外。其中本文环境为windows,其它系统可参考进行安装。

 

 一、下载 zip 版 mysql。

下载过程不细说,从 官网 下载对应的版本即可。

 

二、安装配置

将 mysql 解压到某一文件夹下,例如:“ D:\mysql\”。

配置系统变量,右键“我的电脑”——“高级系统设置”——“环境变量”——“系统变量”——“path”,双击打开编辑后,添加 mysql 目录中 bin 目录的路径,例如:“D:\mysql\bin”。

复制一份 my-default.ini 另存为 my.ini,修改 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.

[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 = ./data # 此路径可为绝对或相对路径
port = 3306
# 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数据:

mysqld --initialize

 此命令会生成一个随机的root密码,密码在data目录下,一个以电脑主机名命名的err文件中:

A temporary password is generated for root@localhost: >rqk,nwkz9pI

你也可以使用空密码初始化MySQL:

mysqld --initialize-insecure

然后安装系统服务:

# 安装MySQL服务
mysqld --install
 
# 卸载MySQL服务
mysqld --remove

启动服务:

net start mysql

 

三、修改 mysql 默认密码

登录 mysql:

mysql -uroot -p

密码即上一步生成的随机密码,如果没有密码,直接回车。

修改密码:

set password=password('your password');

 

最后

至此,mysql 解压版已经配置完成。