gpt4 book ai didi

mysql - MacOS Mojave - brew install mysql@5.7 - 用户 'root' @'localhost' 拒绝访问

转载 作者:行者123 更新时间:2023-11-29 02:10:41 24 4
gpt4 key购买 nike

在 MacOS Mojave 上通过 Homebrew 软件(即 brew install mysql@5.7)安装 mysql 时,似乎成功安装会打印以下说明:

We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
mysql -uroot

mysql -urootmysql_secure_installation 运行时,出现以下错误:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

如何登录mysql修改root的密码?

最佳答案

似乎通过 --password 标志使用“空字符串”密码可以解决这个问题:

mysql -uroot --password=""

或者,您可以使用 --skip-grant-tables 手动启动 mysqld:

$ mysql.server --skip-grant-tables
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24 Homebrew

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

$

最后修改密码:

mysqladmin -uroot --password="" password NEW_PASSWORD

关于mysql - MacOS Mojave - brew install mysql@5.7 - 用户 'root' @'localhost' 拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53616701/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com