今天在 Mac 上安装了 MySQL 5.7 ,启动服务后,输入 mysql -u root -p 后,输入初始密码程,尝试执行 show databases;
报了一个 You must reset your password using ALTER USER statement before executing this statement. 错误。
参考 Stack Overflow 上一篇文章 https://stackoverflow.com/questions/33467337/reset-mysql-root-password-using-alter-user-statement-after-install-on-mac
步骤如下:
set password = password('your new password');
alter user 'root'@'localhost' password expire never;
flush privileges;