windows下MySQL解压版安装配置详细步骤

一、下载MySQL数据库解压版并解压
二、配置环境变量

    在系统变量path后面添加MySQL安装路径下的bin目录;
    例:E:\mysql\bin

三、修改MySQL配置文件

    在MySQL安装目录下有一个my-default.ini文件,复制一份,改名为my.ini,修改里面的配置。
原始文件my-default.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 = .....
# port = .....
# 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 

    修改其中的basedir;datadir;port。
    basedir为MySQL安装根路径,datadir为MySQL安装根目录下的data文件夹路径。port为默认端口号。
例:
修改后文件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.

[mysql]
 default-character-set=utf8 

[mysqld]
#skip-grant-tables
# 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 = E:\mysql
datadir = E:\mysql\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服务

    1.以管理员身份打开命令提示符,进入到MySQL安装路径bin目录。执行命令:mysqld -install将mysql安装到windows的服务。如需移除,执行mysqld --remove移除服务。
    2.输入命令:mysqld --initialize ,这一步用于初始化data目录,官方的压缩包解压后并没有data文件夹,运行命令后,自动在根目录下生成data文件夹。

五、启动MySQL服务

    在命令提示符执行 net start mysql启动MySQL服务;执行net stop mysql停止服务。

六、登录维护MySQL

    MySQL默认用户名为root,密码为空。初次安装完成后可以直接进入安装路径的bin目录,执行mysql -u root -p,此时会提示输入密码,直接回车跳过,登录成功。如需设置密码,执行mysqladmin -uroot -p password <新密码>命令,会提示输入旧密码,旧密码为空,直接回车跳过。
    新版本的MySQL中,root用户的密码不能为空,在使用前必须设置密码。
    1.在配置文件my.ini中,[mysqld]后一行加入skip-grant-tables;
    2.重启MySQL服务;
    3.执行mysql -u root -p,此时会提示输入密码,直接回车跳过,登录成功。
    4.选择mysql数据库。执行use mysql;
    5.对user表执行更新操作。update user set authentication_string=password("你的密码") where user="root"; 
    6.刷新MySQL的系统权限相关表。执行flush privileges 。刷新后退出,执行quit 。mysql 新设置用户或更改密码后需刷新相关表,否则会出现拒绝访问。
    7.重新启动MySQL服务。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值