Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql rebuilds a user account (ERROR 1396 (HY00)

Shulou Source: shulou.com Published: 2022-06-01 09:40:06 10月03日 Update

Description: after the user molewan is deleted in MariaDB, the business needs to re-establish a user named molewan

1. Check the database and find that there are no molewan users anymore.

MariaDB [mysql] > select user,host from mysql.user;+-+-+ | user | host | +-+-+ | molewan1 | 10.10.10.% | | admin | localhost | +-+-+ 2 rows in set (0.00 sec)

2. Create a new molewan user and report an error

MariaDB [mysql] > create user molewan@'10.10.10.%' identified by 'molewan';ERROR 1396 (HY000): when Operation CREATE USER failed for' molewan'@'10.10.10.%' remembered to delete a molewan user, it was MariaDB [mysql] > delete from mysql.user where user= "molewan1" and host = "10.10.10.%" deleted by the delete command; MariaDB [mysql] > flush privileges

3. Check the information and find that if you want to completely not apply to a certain user, it is recommended to use the drop command.

MariaDB [mysql] > drop user molewan@'10.10.10.%';Query OK, 0 rows affected (0.00 sec) MariaDB [mysql] > flush privileges;Query OK, 0 rows affected (0.00 sec)

Additional note: DROP USER will not automatically terminate the connected user session, that is, if the deleted user has connected to the server before deletion and the connection has not been interrupted, it can continue to perform certain operations at this time, but its identity has changed to household registration.

4. Users who rebuild molewan

MariaDB [mysql] > create user molewan@'10.10.10.%' identified by 'molewan';Query OK, 0 rows affected (0.01sec) MariaDB [mysql] > select user,host from mysql.user +-+-+ | user | host | +-+-+ | molewan | 10.10.10.% | | admin | localhost | +-+-+ 2 rows in set (0.00 sec)

Tags: User command business that is that is just not yet data database time server data identity demand household registration is not registered recommendation service account Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB NVidia Shulou Technology Shulou Information MySQL