Home >Database >Mysql Tutorial >Why Can't I Recreate MySQL User 'jack'@'localhost' Despite Being Root?

Why Can't I Recreate MySQL User 'jack'@'localhost' Despite Being Root?

DDD
DDDOriginal
2024-12-09 20:13:15238browse

Why Can't I Recreate MySQL User 'jack'@'localhost' Despite Being Root?

MySQL: Error 1396 Operation CREATE USER Failed for 'jack'@'localhost'

Problem:

In MySQL, despite being root, the user faces an inability to recreate a deleted user 'jack' with the error message: "Operation CREATE USER failed for 'jack'@'localhost'".

Additional Context:

The error only occurs for the user 'jack' and not for other usernames, indicating a potential corruption issue specifically related to 'jack'. The user table in mysql.user shows no remnants of the deleted 'jack' user.

Solution:

Step 1: Drop the Existing User

Assume that the user 'jack' still exists, even if the user table does not show it. Execute the following command to drop the user:

drop user jack@localhost;

Step 2: Flush Privileges

To purge any cached privileges associated with the potentially corrupted user, flush the privileges using the following command:

flush privileges;

Step 3: Recreate the User

Now, you can create the user 'jack' as desired:

create user jack@localhost identified by 'test123';

This workaround should resolve the issue and allow you to create the user 'jack' successfully.

The above is the detailed content of Why Can't I Recreate MySQL User 'jack'@'localhost' Despite Being Root?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn