我最近安装了MySQL,似乎在安装后我必须重置密码。它不让我做别的事。

现在我已经用通常的方式重置了密码:

update user set password = password('XXX') where user = root;

(顺便说一句:我花了很长时间才发现MySQL出于某种奇怪的原因将字段“password”重命名为“authentication_string”。我对这样的变化感到很不安。

不幸的是,似乎我需要改变密码不同的方式,我不知道。也许在座有人已经遇到过这个问题了?


当前回答

在version 14.14 Distrib 5.7.19, macos10.12 (x86_64)上,我以以下方式登录: mysql -uroot -p然后在安装时输入mysql生成的密码。然后. .

ALTER USER 'root'@'localhost' IDENTIFIED BY '<new_password>';

例子:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Ab1234'; 查询OK, 0行受影响(0.00秒) mysql >退出 再见 $ mysql -uroot -p

你可以输入" Ab1234 "

其他回答

MySQL 5.7。X你需要切换到本地密码才能改变它,比如:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';

我在Mac上也有同样的问题

首先,用沙箱模式登录mysql

mysql -u <user> -p --connect-expired-password

然后,设置密码

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('XXXX');

Query OK, 0 rows affected, 1 warning (0.01 sec)

它适用于我~

通过https://dba.stackexchange.com/questions/118852/your-paswssword-has-expired-after-restart-mysql-when-updated-mysql-5-7-8-rcde

mysql> SET PASSWORD = PASSWORD('your_new_password'); 这对我很有用。

这招对我很管用:

ALTER USER(用户名)

我在这里找到的: http://dev.mysql.com/doc/refman/5.7/en/alter-user.html#alter-user-current

记住版本5.7.23及以上-用户表没有列密码,而是认证字符串,所以下面的工作,而重置用户的密码。

update user set authentication_string=password('root') where user='root';