2

I have installed Mysql Ver 14.14 Distrib 5.7.9, for Linux (x86_64) using EditLine wrapper On CentOS Linux release 7.1.1503

I Changed root password using this command:

alter user 'root'@'localhost' identified by 'XXXXXXX';  
flush privileges;

After re-login

[root@server ~]# mysql -u root -p
Enter password: 

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

3 Answers 3

18

Two things have changed since earlier versions of mySQL (I''m using 5.7.10):

  1. systemd is now used to look after mySQL instead of mysqld_safe (which is why I was getting the -bash: mysqld_safe: command not found error - it's not installed)

  2. The user table structure has changed.

So to reset the root password, you still start mySQL with --skip-grant-tables options and update the user table, but how you do it has changed.

1. Stop mysql:
systemctl stop mysqld

2. Set the mySQL environment option 
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set
systemctl start mysqld

4. Login as root
mysql -u root

5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword')
    -> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

6. Stop mysql
systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time
systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:
systemctl start mysqld

Try to login using your new password:
7. mysql -u root -p

Reference

As it says at http://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html,

Note

As of MySQL 5.7.6, for MySQL installation using an RPM distribution, server startup and shutdown is managed by systemd on several Linux platforms. On these platforms, mysqld_safe is no longer installed because it is unnecessary. For more information, see Section 2.5.10, “Managing MySQL Server with systemd”.

Which takes you to http://dev.mysql.com/doc/refman/5.7/en/server-management-using-systemd.html where it mentions the systemctl set-environment MYSQLD_OPTS= towards the bottom of the page.

The password reset commands are at the bottom of http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

1
  • After using your instruction for resetting MySQL root password, I got ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. after executing every command in MySQL prompt, even after ALTER USER root IDENTIFIED BY 'MY_NEW_PASSWORD'; I did a search and then found the solution here https://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html. You need to run ALTER USER USER() IDENTIFIED BY 'new_password'; in MySQL console. Apr 24, 2016 at 4:43
1

You should use update on mysql user table when changing any user, especially root.

You should follow these steps to reset it:

How to reset the root password for mysql:
Stop mysql:
1. service mysql stop

Run mysql with skip grants to be able to login without any password
2. mysqld_safe --skip-grant-tables &

Login as root
3. mysql -u root

4. mysql commands:
mysql> use mysql;
mysql> update user set password=PASSWORD("YourPWHere") where User='root';
mysql> flush privileges;
mysql> quit

Stop mysql
5. service mysql stop

Start mysql normally:
6. service mysql start

Try to login using your new password:
7. mysql -u root -p

Update:

Apparently this method will not work for 5.7, please refer to Here and Here instead.

4
  • The problem is "As of MySQL 5.7.6, for MySQL installation using an RPM distribution, server startup and shutdown is managed by systemd on several Linux platforms. On these platforms, mysqld_safe is no longer installed because it is unnecessary. For more information, see Section 2.5.10, “Managing MySQL Server with systemd”." Oct 27, 2015 at 21:36
  • 1
    As I said I'm using Mysql 5.7.9 on Centos 7.1 and mysqld_safe command DOES'NT exists ! Oct 27, 2015 at 22:32
  • read what it says at the end of the link above...Because mysqld_safe is not installed when systemd is used, options previously specified for that program (for example, in an [mysqld_safe] option group) must be specified another way....I have not really done anything with 5.7 and we have not moved to CentOS 7, CASE IN POINT HERE...
    – BK435
    Oct 27, 2015 at 23:10
  • and what other way is this?
    – user2312578
    Dec 4, 2015 at 23:33
0

Use the below Steps to reset the password.

$ sudo systemctl start mysqld

Reset the MySql server root password.

$sudo grep 'temporary password' /var/log/mysqld.log

Output Something like-:

     10.744785Z 1 [Note] A temporary password is generated for root@localhost: o!5y,oJGALQa

Use the above password during reset mysql_secure_installation process.

   $ sudo mysql_secure_installation
       Securing the MySQL server deployment.

       Enter password for user root: 

You have successfully reset the root password of MySql Server. Use the below command to check the mysql server connecting or not.

$ mysql -u root -p

See my article: Install Latest MySQL 5.7 on RHEL/Centos 7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.