Windows配置MySQL(5.6.20)免安装版

时间:2022-01-17 17:10:08

1.首先到http://dev.mysql.com/ 上下载windows版mysql5.6免安装zip包。然后将zip包解压到D:\mysql-5.6.20-winx64下。

2.在D:\mysql-5.6.20-winx64下创建my.ini。

注意!!!如果你不是解压到D:\mysql-5.6.20-winx64下面第23、24、29、31行的代码要改成你的安装目录!!!

内容如下:

# 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]
character-set-server=utf8

# 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 = .....
basedir=D:/mysql-5.6.20-winx64
datadir=D:/mysql-5.6.20-winx64/data
port=13306

character-set-server=utf8
default-storage-engine=INNODB
innodb_data_home_dir=D:/mysql-5.6.20-winx64/data
innodb_data_file_path=ibdata1:12M:autoextend
innodb_log_group_home_dir=D:/mysql-5.6.20-winx64/data

innodb_buffer_pool_size=10240M
innodb_log_file_size=4G
innodb_lock_wait_timeout = 500
# 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
3.设置环境变量。

进入系统属性,点下面的环境变量。

Windows配置MySQL(5.6.20)免安装版

系统变量底下点新建

Windows配置MySQL(5.6.20)免安装版

如下图所示,填写完毕后点确定。(我的是D:\mysql-5.6.20-winx64\bin,你需要改成自己的bin目录

Windows配置MySQL(5.6.20)免安装版

找到系统变量中的Path,点下面的编辑。

Windows配置MySQL(5.6.20)免安装版

点编辑文本。

Windows配置MySQL(5.6.20)免安装版

在变量值最后加上;%MYSQL_HOME%(注意前面有分号后面没有分号!!!)

Windows配置MySQL(5.6.20)免安装版

4.管理员身份进入命令提示符

输入:

mysqld --console
Windows配置MySQL(5.6.20)免安装版
5.注册mysql为windows service. 以后可以使用windows service来安装mysql和卸载mysql的服务。

进入D:\mysql-5.6.20-winx64\bin目录

Windows配置MySQL(5.6.20)免安装版

安装mysql服务

mysqld install

Windows配置MySQL(5.6.20)免安装版

(卸载mysql服务 mysqld remove


进入服务,控制面板-管理工具-服务(以管理员身份运行)

Windows配置MySQL(5.6.20)免安装版

Windows配置MySQL(5.6.20)免安装版

启动MySQL服务

Windows配置MySQL(5.6.20)免安装版


net start mysql --启动mysql服务
net stop mysql --停止mysql服务

Windows配置MySQL(5.6.20)免安装版


使用root用户登陆数据库,端口号为13306,密码为空

mysql -P13306 -u root -p

查看数据库文件存放路径

show global variables like "%datadir%";

查看所有数据库

show databases;

密码改为ROOT

GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'ROOT';

Windows配置MySQL(5.6.20)免安装版


show engines; --查看MySQL存储引擎
\q --退出MySQL

Windows配置MySQL(5.6.20)免安装版