Mysql8.0数据库修改密码/无法修改密码【改用"mysqld --console --skip-grant-tables --shared-memory"修改密码】

本文参考了:https://www.pianshen.com/article/7287279782/

一、关闭SQL

第一种方法:
windows键+r,输入services.msc,点确定,如下所示
在这里插入图片描述再找到MYSQL右键停止服务,
在这里插入图片描述
第二种方法:
如下所示用管理员身份打开命令行
在这里插入图片描述
cmd命令行输入:net stop mysql; 服务停止中 -> 服务已停止,如下所示
在这里插入图片描述

二、打开cmd界面,定位到mysql安装目录的bin文件下

也就是找到这个目录的里面的bin,里面放的是mysql.exe及mysqld.exe等,:
在这里插入图片描述

输入

cd C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin

(注:地址是你自己的安装目录地址)

三、启动MySQL服务的时候跳过权限表认证

很多博主是输入“mysqld --skip-grant-tables ”,但是最新的数据库版本这个命令已失效,会发现命令窗口仍然跳出下一行待输入指令。

应该输入:

mysqld --console --skip-grant-tables --shared-memory

生成界面如下,此时dos窗口不能运行,再另开一个cmd窗口操作第四步。【我之前一直以为这样的是错误的界面,然而还是太天真了,其实这就是可以了,然后直接另开一个cmd去绕过修改mysql的密码的了。所以如果是下图这种情况,就可以直接去第四步了。】
在这里插入图片描述注意:有可能会出现下图的情况
在这里插入图片描述也就是这个InnoDB: The InnoDB memory heap is disabled错误情况。

这个错误的解决方法,就是在你的my.ini【Linux系统是my.cnf文件】里面的[mysqld]下面加一行
在这里插入图片描述
指代存放的地址空间到E盘的MySQL Datafiles,如果直接重启的话,文件夹会有如下情况:
在这里插入图片描述
如果还没有解决的话,就是找到你的存放数据库的data文件夹内,也就是根据你my.ini里面的datadir变量所指的路径我的是这个,如下图所示
在这里插入图片描述
删除掉下面三个文件:
在这里插入图片描述>然后再重启mysql,基本上都能解决了。如果还不行,那我也没辙了,或者你可以下一下我待会上次的my.ini,是mysql5.5的,记得要改里面的basedir和datadir变量值就是了。

四、直接输入’mysql’免密登入数据库

输入 mysql,如果成功,显示如下界面,下一行的提示命令为mysql
在这里插入图片描述

五、输入’ use mysql '连接权限数据库

在这里插入图片描述

六、输入’ show tables; '(分号注意)

在这里插入图片描述

显示图片如下,最下面有一个user,里面就有我们想要的信息。
在这里插入图片描述

七、注意这里的第一种情况对应八的第一种情况处理,第二种情况对应八的第二种情况处理【我个人是属于第一种情况。】

**第一种情况输入:select user,host,password from user; 查看user信息如下图所示

在这里插入图片描述
如果提示错误ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’,就看第二种情况

第二种情况输入:select user,host from user; 查看user信息在这里插入图片描述

八、修改密码

第一种情况(七中的第一种情况请按照这个来)

update user set password=password("123456") where user="root";

如下图所示:
在这里插入图片描述如果报错,请看情况二:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(‘123’) where user=‘root’ and host=‘localhost’’ at line 1

第二种情况(七中的第二种情况请按照这个来)

update mysql.user set authentication_string="123456" where user="root";

九、刷新权限。输入:flush privileges;(必做)

在这里插入图片描述

最后quit数据库,还会很萌地跟你say bye。

附加问题的解决方法:

ERROR 1130 (HY000): Host ‘127.0.0.1’ is not allowed to connect to this MySQL server

解决方法:注释掉my.ini中的skip_name_resolve

然后还有就是:查看数据库代码:

show databases;

通过命令行进入数据库代码:

mysql -u root -p
//回车,然后输入密码就可以了

写到现在这个博客,真的感慨万分,因为这次的东西是第二次遇见了,上一次也花了好长时间解决了,但是当时是好了伤疤忘了疼,没有写博客。而这次真的是十分地后悔,所以附上一个相对来说比较完整的解决方法吧,希望能够帮到大家!

再次声明:这篇博文参考了:https://www.pianshen.com/article/7287279782/

最后:
这是我my.ini文件的内容:

# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password	= your_password
port		= 3306
socket		= /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port		= 3306
socket		= /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
# 
#skip-networking
server-id	= 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

# binary logging format - mixed recommended
#binlog_format=mixed

# Causes updates to non-transactional engines using statement format to be
# written directly to binary log. Before using this option make sure that
# there are no dependencies between transactional and non-transactional
# tables such as in the statement INSERT INTO t_myisam SELECT * FROM
# t_innodb; otherwise, slaves may diverge from the master.
#binlog_direct_non_transactional_updates=TRUE

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\\mysql\\data\\
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\\mysql\\data\\
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld]
innodb_use_sys_malloc =0
tmpdir = "E:\\MySQL Datafiles"

#设置basedir指向mysql的安装路径
federated
skip-external-locking
#skip-name-resolve
basedir=C:\Program Files (x86)\MySQL\MySQL Server 5.5
datadir=C:\ProgramData\MySQL\MySQL Server 5.5\data
### 解析 Node.js 中 `Cannot find module 'node:fs/promises'` 的解决方案 当遇到 `Error: Cannot find module 'node:fs/promises'` 时,通常表明当前使用的 Node.js 版本较低,无法识别新的内置模块路径。此问题常见于 Webpack 或其他构建工具集成 Babel 后,在尝试访问新特性如 `fs.promises` API 时发生。 #### 方法一:升级 Node.js 到兼容版本 确保使用最新稳定版的 Node.js 是最直接有效的办法之一。Node.js v14.x 开始正式支持 ES 模块语法下的核心模块前缀 `node:`,因此建议至少更新至该版本以上[^2]。 如果因项目需求或其他原因暂时不便更换 Node.js 主版本,则可考虑调整代码逻辑以适应现有环境: #### 方法二:修改代码适配旧版 Node.js 对于特定文件内发生的此类错误,比如 Electron 应用中的情况,可以通过替换原有写法来规避不兼容的问题。例如将原生导入语句改为传统形式,并利用解构赋值获取所需功能对象: ```javascript // 原有代码可能形似这样 const promises_1 = require("fs/promises"); // 调整后的代码应如此编写 const fs = require('fs'); const { promises } = fs; ``` 这种方法允许继续沿用 promise 风格的操作接口而不必担心底层实现差异带来的影响[^3]。 #### 方法三:处理包管理器与编译工具链之间的潜在冲突 有时即使 Node.js 已经满足条件,仍会出现相同报错现象。这可能是由于本地 npm/cnpm 安装源设置不当或是某些开发依赖项之间存在版本矛盾所致。针对这种情况,推荐先清理缓存再重试安装必要的构建插件;必要时卸载引起争议的具体库并指定确切版本号重新拉取[^5]: ```bash # 清理 cnpm/npm 缓存 cnpm cache clean --force rm -rf node_modules package-lock.json yarn.lock # 移除有问题的 loader 并重建 npm uninstall babel-loader @babel/core npm install --save-dev babel-loader@latest @babel/core@latest ``` 上述措施有助于排除由外部因素引发的一系列连锁反应,恢复正常的打包流程。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值