问题描述
我是整个Mac体验的新手.我最近安装了MySQL,安装后似乎必须重置密码.它不会让我做任何其他事情.
I'm new to the whole Mac experience. I recently installed MySQL and it seems I have to reset the password after install. It won't let me do anything else.
现在,我已经以通常的方式重置了密码:
Now I already reset the password the usual way:
update user set password = password('XXX') where user = root;
(顺便说一句:(我花了很长时间才弄清楚,MySQL由于某种奇怪的原因已将字段"password"重命名为"authentication_string".对于这样的更改,我感到很沮丧.)
(BTW: took me ages to work out that MySQL for some bizarre reason has renamed the field 'password' to 'authentication_string'. I am quite upset about changes like that.)
不幸的是,我似乎需要以一种我不知道的其他方式更改密码.也许这里有人已经遇到了这个问题?
Unfortunately it seems I need to change the password a different way that is unknown to me. Maybe someone here has already come across that problem?
推荐答案
如果这不是您第一次设置密码,请尝试以下方法:
If this is NOT your first time setting up the password, try this method:
mysql> UPDATE mysql.user SET Password=PASSWORD('your_new_password')
WHERE User='root';
如果出现以下错误,则很有可能以前从未设置过密码:
And if you get the following error, there is a high chance that you have never set your password before:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
要首次设置密码:
mysql> SET PASSWORD = PASSWORD('your_new_password');
Query OK, 0 rows affected, 1 warning (0.01 sec)
参考: https://dev.mysql.com/doc/refman/5.6/en/alter-user.html
这篇关于在Mac上安装后,使用ALTER USER语句重置MySQL根密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!