(实践应用)CentOS + MySQL5.7 Have No mysqld_safe

前端之家收集整理的这篇文章主要介绍了(实践应用)CentOS + MySQL5.7 Have No mysqld_safe前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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.

    @H_502_8@
  • Stop MysqL:
    systemctl stop MysqLd

  • Set the MysqL environment option
    systemctl set-environment MysqLD_OPTS=”–skip-grant-tables”

  • Start MysqL usig the options you just set
    systemctl start MysqLd

  • Login as root
    MysqL -u root

  • 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

  • Stop MysqL
    systemctl stop MysqLd

  • Unset the MysqL envitroment option so it starts normally next time
    systemctl unset-environment MysqLD_OPTS

  • Start MysqL normally:
    systemctl start MysqLd

  • Try 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

猜你在找的CentOS相关文章