MacOS Mojave - brew install [email protected] - 用户'root'@'localhost'拒绝访问

问题描述 投票:2回答:2

在MacOS Mojave上通过homebrew(即qazxsw poi)安装mysql时,看似成功的安装会打印以下说明:

brew install [email protected]

当运行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 -uroot时,我收到以下错误:

mysql_secure_installation

如何登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 更改mysql的密码?

mysql homebrew mysql-5.7 macos-mojave
2个回答
2
投票

似乎通过root标志使用“空字符串”密码解决了这个问题:

--password

或者,您可以使用mysql -uroot --password="" 手动启动mysqld

--skip-grant-tables

最后用以下内容更改密码:

$ 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.

$ 

0
投票

新的brew mysql安装完成后:

1)确保mysql正在运行:brew services启动mysql

2)更改mysql密码:mysqladmin -uroot --password =“”密码'NEWPASSWORD'

3)安全mysql:mysql_secure_installation(使用新密码)

© www.soinside.com 2019 - 2024. All rights reserved.