简体   繁体   English

MYSQL丢失用户密码

[英]MYSQL loses user password

I use c++ to search info in database, using 'user1' and password. 我使用c++使用“ user1”和密码来搜索数据库中的信息。 I don't input password manually. 我没有手动输入密码。 I receive it from docker secrets. 我是从Docker机密中收到的。 But some times I have an error: 但是有时候我有一个错误:

Access denied for user 'user1'@'localhost' (using password: YES) 用户'user1'@'localhost'的访问被拒绝(使用密码:是)

In this case I just do drop user user1 and create new one: 在这种情况下,我只是drop user user1并创建一个新drop user user1

CREATE USER IF NOT EXISTS 'user1'@'%' IDENTIFIED BY 'password';
GRANT some PRIVILEGES ON some_db TO 'user'@'%';

Why do I have sometimes a problem with a password in MYSQL? 为什么有时我的MYSQL密码有问题?

MYSQL loses user password MYSQL丢失用户密码

Given your description, I suspect the issue is arising outside of MySQL - a tool specifically designed for and trusted by a lot of people to retain data - or a misunderstanding of how MySQL authentication works. 根据您的描述,我怀疑问题出在MySQL之外-一种专门为许多人设计并受许多人信任的工具,用于保留数据-或对MySQL身份验证的工作方式有误解。

'user1'@'%' is quite different from 'user1'@'localhost' ; 'user1'@'%''user1'@'localhost'完全不同; in mysql.user the wildcard does not match localhost on POSIX systems. 在mysql.user中,通配符与 POSIX系统上的localhost不匹配

Given that the only information you've provided about the issue appears to be incorrect, its rather hard to suggest how to resolve it. 鉴于您提供的有关该问题的唯一信息似乎不正确,因此很难提出解决方案。

If you really are connecting to localhost, then using peercred (enabled by default in recent implementations of MySQL and MariaDB) is a lot simpler and more secure. 如果您确实要连接到localhost,则使用peercred (在MySQL和MariaDB的最新实现中默认启用)会更简单,更安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM