CentOs7 mysql更改密码

来源:互联网 发布:php小型博客开源框架 编辑:程序博客网 时间:2024/05/20 16:37
  1. 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)

  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 mysqld2. Set the mySQL environment option systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"3. Start mysql usig the options you just setsystemctl start mysqld4. Login as rootmysql -u root5. Update the root user password with these mysql commandsmysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword')    -> WHERE User = 'root' AND Host = 'localhost';mysql> FLUSH PRIVILEGES;mysql> quit6. Stop mysqlsystemctl stop mysqld7. Unset the mySQL envitroment option so it starts normally next timesystemctl unset-environment MYSQLD_OPTS8. Start mysql normally:systemctl start mysqldTry 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,

0 0
原创粉丝点击