Resetting root password for mariadb does not work(重置 mariadb 的 root 密码不起作用)
问题描述
我正在尝试重置 mariadb 数据库的 root 密码,遵循了迄今为止我发现的每个教程变体,并且每次尝试使用新密码登录时,它都不接受它.
I am trying to reset the root password for a mariadb database, followed every variation of tutorial to do so I've found so far, and every time I try to log in with the new password, it does not accept it.
主要是我一直在做的:
mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root -e 'use mysql; update user SET PASSWORD=PASSWORD("jkjkjkjjk"); flush privileges;'
我还尝试在 udpate 命令之前添加一个额外的 flush 权限;,也将其从末尾删除,重置密码的不同变体,例如 为 'root'@'localhost' 设置密码 = PASSWORD('new_password');
I also tried adding an additional flush privileges; before the udpate command, removing it from the end as well, different variations for reset password, such as SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
如果相关,我正在使用 mariadb 和 galera,在 kubernetes statefulset 上运行.mariadb 的版本是 mysqld 10.3.21-MariaDB-1:10.3.21+maria~bionic
I am using mariadb with galera, running on kubernetes statefulset, if relevant.
version of mariadb is mysqld 10.3.21-MariaDB-1:10.3.21+maria~bionic
我对此感到非常沮丧.
推荐答案
你要做的是:
用类似的东西停止mysql服务:
stop the mysql service with something like:
sudo systemctl stop mariadb
然后重启
sudo mysqld_safe --skip-grant-tables &
无密码登录
mysql -u root
更新密码
use mysql;
update user SET PASSWORD=PASSWORD("password") WHERE USER='root';
flush privileges;
exit
正常重启数据库
sudo systemctl start mariadb
这假设您使用的是 linux 机器并且您可以访问 shell.请注意,在您的更新查询中,您还缺少 where 子句,以便您使用相同的密码更新所有用户!
This assuming you are using a linux machine and you have access to the shell. Note that in your update query you are also missing the where clause so that you are updating ALL your users with the same password!
这篇关于重置 mariadb 的 root 密码不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:重置 mariadb 的 root 密码不起作用
基础教程推荐
- 无法解决整理冲突 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
