windows安装MySQL

一、下载MySQL压缩包并解压
https://dev.mysql.com/downloads/mysql/
这里写图片描述

二、进入MySQL安装目录,在安装目录下修改或新建后缀名为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 = D:\Java\mysql-5.7
datadir = D:\Java\mysql-5.7\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 数据
使用管理员权限运行cmd.exe,转到MySQL的bin目录下,输入

mysqld --initialize

四、安装MySQL服务

mysqld install(注:删除服务命令为mysqld remove需要先停止服务)

显示service successfully installed说明MySQL服务安装成功
可尝试通过net start mysql命令启动MySQL服务(注:停止服务命令为net stop mysql
或通过控制面板>系统和安全>管理工具>服务,打开服务窗口。找到MySQL服务,并手动启动。
这里写图片描述

五、在 cmd 中登录mysql

mysql -u rooy -p

在MySQL安装目录/data目录下有计算机名.err文件,双击打开,搜索
A temporary password,找到

[Note] A temporary password is generated for root@localhost: o5tECjj4Bd;J

注:如果运气不好,随机的密码可能含有了不支持的字符,那就删了再来一遍吧!!!

修改密码命令:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

六、问题解决

1.如果MySQL服务无法正常启动,可进入MySQL安装目录,查看是否有data目录,有的话删除data目录,并在控制台中输入命令初始化MySQL

mysqld --initialize

仍无法启动,将my.ini文件设置路径的分割符由“\”改为“\\”再次初始化mysqld --initialize
再尝试启动MySQL服务net start mysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值