简体   繁体   中英

MYSQL loses user password

I use c++ to search info in database, using 'user1' and password. I don't input password manually. I receive it from docker secrets. But some times I have an error:

Access denied for user 'user1'@'localhost' (using password: YES)

In this case I just do drop user user1 and create new one:

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 loses user password

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.

'user1'@'%' is quite different from 'user1'@'localhost' ; in mysql.user the wildcard does not match localhost on POSIX systems.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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