https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7/34207996#34207996
- systemd is now used to look after MysqL instead of MysqLd_safe (which is why you get the -bash: MysqLd_safe: command not found error - it’s not installed)
The user table structure has changed.
Set the MysqL environment option
systemctl set-environment MysqLD_OPTS=”–skip-grant-tables”Start MysqL usig the options you just set
systemctl start MysqLdLogin as root
MysqL -u rootUpdate 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> quitUnset the MysqL envitroment option so it starts normally next time
systemctl unset-environment MysqLD_OPTSTry to login using your new password:
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