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

标签 mysql homebrew mysql-5.7 macos-mojave

在 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/

相关文章:

xcode - Homebrew 说 Xcode 已过时

mysql - 安装Mysql 5.7失败

MySQL 日期字段不响应查询中的 ASC 或 DESC

php - php中更新数据的问题

MySQL 服务器套接字 '/tmp/mysql.sock' 连接问题

mysql - 使用 Ansible 创建 MySQL 表

mysql - Brew 安装 MySQL,El Capitan 请求循环

MYSQL 日期验证令人头疼

python - 与我的 MYSQL connect_timeout 单位混淆

MySQL - 提取括号中的值 [...]