Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Won't let User Login: Error 1524

Tags:

sql

mysql

Server version: 5.7.10 MySQL Community Server (GPL)

In MySQL, I have a user mangos. The user worked perfectly when I created it. After rebooting my computer, though, attempting to login to mangos yielded this output:

$ mysql -u mangos -p
Enter password: 
ERROR 1524 (HY000): Plugin '*some_random_long_hash_I_cannot_remember' is not loaded
$ 

It kind of reminded me of a password hash, so after investigating mysql.user, I found that mangos had no password! I updated the password:

SET PASSWORD FOR 'mangos'@'127.0.0.1' = PASSWORD('mangos');
FLUSH PRIVILEGES;

Now, I get:

ERROR 1524 (HY000): Plugin '*3FBBDB84EA2B2A0EA599948396AD622B7FF68183' is not loaded

3FBBDB84EA2B2A0EA599948396AD622B7FF68183 is the same number shown in the password column of mysql.user for mangos, and is a different number than originally. I still can't log in.

How do I make MySQL recognize a password properly? Is that even the issue here?

Edits:

mysql> SELECT * FROM mysql.user WHERE user = 'mangos' \G
*************************** 1. row ***************************
Host: localhost
              User: mangos
          Password: *3FBBDB84EA2B2A0EA599948396AD622B7FF68183
       Select_priv: N
       Insert_priv: N
       Update_priv: N
       Delete_priv: N
       Create_priv: N
         Drop_priv: N
       Reload_priv: N
     Shutdown_priv: N
      Process_priv: N
         File_priv: N
        Grant_priv: N
   References_priv: N
        Index_priv: N
        Alter_priv: N
      Show_db_priv: N
        Super_priv: N
Create_tmp_table_priv: N
      Lock_tables_priv: N
          Execute_priv: N
       Repl_slave_priv: N
      Repl_client_priv: N
      Create_view_priv: N
        Show_view_priv: N
   Create_routine_priv: N
    Alter_routine_priv: N
      Create_user_priv: N
            Event_priv: N
          Trigger_priv: N
Create_tablespace_priv: N
              ssl_type: 
            ssl_cipher: 
           x509_issuer: 
          x509_subject: 
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: *3FBBDB84EA2B2A0EA599948396AD622B7FF68183
 authentication_string: NULL
      password_expired: N
like image 640
MikeJava Avatar asked Jan 21 '16 22:01

MikeJava


3 Answers

It appears your user table is corrupted. Likely the reboot you mentioned triggered an upgrade to MySQL and the mysql_upgrade script was not run. This should resolve the situation:

mysql_upgrade -u root -ppassword --skip-grant-tables
mysql -u root -ppassword -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'mangos'; FLUSH PRIVILEGES"

Source: http://kb.odin.com/en/126676

Providing the --force option to mysql_upgrade will re-apply the upgrade scripts even if an upgrade has already been done. This may be needed in case of partial restoration from backup.

Also worth mentioning, the command to change a user password has changed in MySQL 5.7.6 / MariaDB 10.2.0 and forward:

ALTER USER mangos IDENTIFIED BY 'mangos';

This is now the preferred method for setting the password, although the older SET PASSWORD syntax is not officially deprecated.

like image 59
miken32 Avatar answered Nov 06 '22 18:11

miken32


mysql_upgrade (suggested by @miken32) wasn't working for me, so I had to do it the hard way, by shutting down the service and using mysqld_safe, as explained here.

UPDATE: Actually, that didn't work either, so I had to do the hard hard hard way (beware, this deletes all your databases):

  1. sudo killall mysqld
  2. sudo rm -rf /var/lib/mysql
  3. sudo apt-get purge mysql-server
  4. Install mysql-server package again.
like image 4
knocte Avatar answered Nov 06 '22 17:11

knocte


I got the issue resolved from here. Run mysql_upgrade -u root -p to fix the issue or if you are facing this error while creating a user than try using "BY" instead of "WITH" in your query.

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'xyz';
like image 1
Ajeet Khan Avatar answered Nov 06 '22 16:11

Ajeet Khan