docker mysql 忘记密码_Mysql账号密码忘记了怎么办?

长时间使用非关系型数据库MongoDB近期遇到突然想使用mysql却发现mysql密码忘记了。。。就我遇到的情况记录一下解决方案

1、常见的一种解决方案是修改配置文件my.ini文件skip-grant-tables 然后重启忽略登录验证的一种方式

2、但我发现现在下载的mysql都是这种目录的

安装之后没有my.ini文件

所以记录一个安装的mysql服务又没有my.ini配置文件忘记密码了该怎么办

步骤如下:

先删除mysql服务

以管理员身份打开cmd进去mysql bin(如果没有设置环境变量)执行

sc delete Mysql(名称是自己的服务器名称)

然后自己新建一个my.ini文件

# 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.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect='SET NAMES utf8mb4'
# 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 FilesMySQLMySQL Server 5.7
datadir = C:Program FilesMySQLMySQL Server 5.7Data
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 = 16M
read_rnd_buffer_size = 16M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

48aa7cb0f019444b0fb096e3206ed023.png

注意修改basedir以及datadir

最后重新初始化mysql服务同时指定新建的my.ini作为服务默认的配置文件

mysqld --initialize-insecure --user=mysql

等待该命令结束之后安装mysql服务绑定my.ini配置文件

mysqld --install "MySql" --defaults-file="my.ini url"

重新安装好服务之后启动net start MySql首次进入不需要密码

mysql -u root -p

回车进入mysql并设置密码即可(根据版本选择命令)

update mysql.user set authentication_string=password("你的密码") where user="root";
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

完成之后推出完事

exit
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值