前提:
mac中之前安装了mysql,一段时间没使用,今天使用mysql客户端去连接,报错提示密码过期,原因是mysql5.7之后版本有密码过期这个功能。
error:
Your password has expired. To log in you must change it using a client that supports expired passwords.
打开终端,启动mysql服务:
sudo /usr/local/mysql/support-files/mysql.server start
打开另外一个终端:
输入:
yingmuxiaogedeMacBook-Air:~ yingmuxiaoge$ alias mysql=/usr/local/mysql/bin/mysql
yingmuxiaogedeMacBook-Air:~ yingmuxiaoge$ mysql -u root -p
输入如下尝试修改密码失败:
mysql> update mysql.user set password=PASSWORD('root') where User='root';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
根据提示信息,使用如下去修改密码:
mysql> alter user 'root'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
修改密码成功。