Reset MySQL root password using ALTER USER statement after install on Mac(在 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 出于某种奇怪的原因将字段密码"重命名为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 根密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Mac 上安装后使用 ALTER USER 语句重置 MySQL 根密码
基础教程推荐
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01