Sembra che io non sia in grado di ricreare un semplice utente che ho cancellato, anche come root in MySQL.
Il mio caso: l'utente 'jack' esisteva prima, ma l'ho cancellato da mysql.user per ricrearlo. Non vedo tracce di questo in quella tabella. Se eseguo questo comando per qualche altro nome utente casuale, diciamo 'jimmy', funziona bene (proprio come ha fatto originariamente per 'jack').
Cosa ho fatto per corrompere l'utente 'jack' e come posso annullare questa corruzione per ricreare 'jack' come un utente valido per questa installazione di MySQL?
Vedi l'esempio qui sotto. (Naturalmente, in origine, c'è stato molto tempo tra la creazione di 'jack' e la sua rimozione).
mysql> CREATE USER 'jack'@'localhost' IDENTIFIED BY 'test123';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from user;
+------------------+-----------------+
| user | host |
+------------------+-----------------+
| root | 127.0.0.1 |
| debian-sys-maint | localhost |
| jack | localhost |
| root | localhost |
| root | russ-elite-book |
+------------------+-----------------+
5 rows in set (0.00 sec)
mysql> delete from user where user = 'jack';
Query OK, 1 row affected (0.00 sec)
mysql> select user,host from user;
+------------------+-----------------+
| user | host |
+------------------+-----------------+
| root | 127.0.0.1 |
| debian-sys-maint | localhost |
| root | localhost |
| root | russ-elite-book |
+------------------+-----------------+
4 rows in set (0.00 sec)
mysql> CREATE USER 'jack'@'localhost' IDENTIFIED BY 'test123';
ERROR 1396 (HY000): Operation CREATE USER failed for 'jack'@'localhost'
mysql> CREATE USER 'jimmy'@'localhost' IDENTIFIED BY 'test123';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from user;
+------------------+-----------------+
| user | host |
+------------------+-----------------+
| root | 127.0.0.1 |
| debian-sys-maint | localhost |
| jimmy | localhost |
| root | localhost |
| root | russ-elite-book |
+------------------+-----------------+
5 rows in set (0.00 sec)
Prova a fare un FLUSH PRIVILEGES
. Questo post sui bug di MySQL su quel codice di errore sembra riportare un certo successo in un caso simile al tuo dopo il flushing dei privilegi.
Non dovresti cancellare manualmente gli utenti in questo modo. MySQL ha la sintassi REVOKE
per rimuovere i privilegi e DROP USER
per cancellarli:
REVOKE priv1,priv2,priv3,etc... FROM 'jack@localhost'; // remove certain privileges
DROP USER 'jack@localhost'; // completely delete the account
E' meglio usare gli strumenti forniti, piuttosto che perdere tempo in background.