在Mac上安装后,使用ALTER USER语句重置MySQL根密码 [英] Reset MySQL root password using ALTER USER statement after install on Mac

查看:461
本文介绍了在Mac上安装后,使用ALTER USER语句重置MySQL根密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是整个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根密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆