mysql - Homebrew Mariadb Mysql 安装 root 访问被拒绝

标签 mysql macos mariadb homebrew

所以我基本上是在我的 mac 上使用 Homebrew 软件安装 mariadb 和 mysql。 这些是我执行的步骤:

  • brew 博士 -> 工作过
  • brew update -> 成功了
  • brew install mariadb -> 成功了
  • mysql_install_db -> 失败

    WARNING: The host 'Toms-MacBook-Pro.local' could not be looked up with /usr/local/Cellar/mariadb/10.4.6_1/bin/resolveip. This probably means that your libc libraries are not 100 % compatible with this binary MariaDB version. The MariaDB daemon, mysqld, should work normally with the exception that host name resolving will not work. This means that you should use IP addresses instead of hostnames when specifying MariaDB privileges ! mysql.user table already exists!

之后运行 mysql_upgrade 出现以下错误:

Version check failed. Got the following error when calling the 'mysql' command line client ERROR 1698 (28000): Access denied for user 'root'@'localhost' FATAL ERROR: Upgrade failed

我不能这样进入mysql:

mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

但是像这样:

sudo mysql -u root

用户表返回这个:

MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+---------------+-------------------------+-----------------------+
| User          | Host                    | plugin                |
+---------------+-------------------------+-----------------------+
| root          | localhost               | mysql_native_password |
| toms          | localhost               | mysql_native_password |
|               | localhost               |                       |
|               | toms-macbook-pro.local |                       |
+---------------+-------------------------+-----------------------+
4 rows in set (0.004 sec)

最佳答案

您可以尝试更新 root 密码并在之后访问它

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

退出Mysql并尝试登录

mysql -uroot -p # then use root as a password

关于mysql - Homebrew Mariadb Mysql 安装 root 访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57803604/

相关文章:

php - 在 MySQL 中存储带有通配符的 URL 并返回匹配项

macos - xcode 像 php 或 perl 一样快速解析文本

MySql Average 和 Group By Usage

php - MariaDB 错误与看似正确的事务 SQL

php - MYSQL 的 BETWEEN 日期的 SQL 查询不包括指定范围?

php - 如何在类中使用PDO连接工作

php - header 、逻辑和数据库

c - 操作系统 : Undefined symbols in C when said symbols exist

mac OS X El Capitan 上的 C++ openmp,Valgrind 错误(数据竞争)

mysql - DNXCORE 5.0 和 mysql/mariadb