mysql安装,找回及设置密码

下载路径: https://dev.mysql.com/downloads/file/?id=480490  (也可下载免安装版)

net start mysql 启动服务

情况1

 

[MySql]默认密码的查找与修改

    在安装成功后,怎么找到mysql的默认密码,折腾很长时间,最后发现在安装的过程中,产生了一个默认的随机密码。

密码
    在mysql安装目录生成的data文件下,查找xxx.err的文件如图:

 

可以看到临时密码:<a5F34))PqMb,使用cmd命令行工具,用临时密码登录,进行修改密码

情况2

解决方法如下:

1. 通过任务管理器结束mysql进程

2. 命令行进入%MYSQL_HOME%\bin目录,输入mysqld --skip-grant-tables(跳过权限检查启动mysql)

3. 打开一个新cmd窗口,输入:mysql,即可登录数据库

4. 输入update mysql.user set authentication_string=password('123') where user='root' and Host ='localhost'; (更新密码)

5. 再次结束所有sql进程,重新启动(net start mysql)并登陆

命令:mysql -u root -p

set password for root@localhost = password('123');

1  修改配置文件basedir和datadir配置。

# 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 =C:\Program Files\MySql\mysql-5.7.17-winx64  #数据库安装路径 关键两行
 datadir =C:\Program Files\MySql\mysql-5.7.17-winx64\data  # 日志放在数据库同一路径,便于查询
# 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

2 添加环境变量

我的电脑->属性->环境变量-PATH

C:\Program Files\MySql\mysql-5.7.17-winx64\bin;

管理员身份运行CMD,并进入bin目录。安装mysql。命令:mysqld -install

最后启动数据库,不同系统版本不一,本文适合win8及mysql 5.7.26

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

**星光*

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值