-1

在我的 Mac 上,我用自制软件安装了 MariaDB;但是,当我尝试登录时,出现以下错误。

ERROR 2002 (HY000): 无法通过套接字 '/tmp/mysql.sock' 连接到本地 MySQL 服务器 (2)

我搜索了 mysql.sock。没有 /tmp/mysql.sock 也没有 /var/lib/mysql.sock。它不存在。

我想我已经阅读了关于这个主题的所有其他帖子,并尝试了很多方法来让它发挥作用;但是,无济于事。所以,我发布了安装、重启和登录的三个步骤,希望有人能看到我在安装过程中遗漏的东西。

(第 1 步)这是我使用 brew 安装 MariaDB 的输出

brew install mariadb
==> Downloading https://ghcr.io/v2/homebrew/core/mariadb/manifests/10.6.4
Already downloaded: /Users/johnDoe/Library/Caches/Homebrew/downloads/bd7a1ecf2f1d64a655dc2f802451f80b56f655802849b44546931d89e6b7475f--mariadb-10.6.4.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mariadb/blobs/sha256:60dbcef58f2dbde95de4461ff84483fee87522bee4cc914f4bc0dfdc9
Already downloaded: /Users/johnDoe/Library/Caches/Homebrew/downloads/a37eb99360886f7cd20e5c7b6972e971657dd48846c9d175b1adf33a860b8c3d--mariadb--10.6.4.arm64_monterey.bottle.tar.gz
==> Pouring mariadb--10.6.4.arm64_monterey.bottle.tar.gz
==> /opt/homebrew/Cellar/mariadb/10.6.4/bin/mysql_install_db --verbose --user=johnDoe --basedir=/opt/homebrew/Cellar/mariadb/10
Last 15 lines from /Users/johnDoe/Library/Logs/Homebrew/mariadb/post_install.01.mysql_install_db:

    shell> /opt/homebrew/Cellar/mariadb/10.6.4/bin/mysql -u root mysql
    mysql> show tables;

Try 'mysqld --help' if you have problems with paths.  Using
--general-log gives you a log in /opt/homebrew/var/mysql that may be helpful.

The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
You can find the latest source at https://downloads.mariadb.org and
the maria-discuss email list at https://launchpad.net/~maria-discuss

Please check all of the above before submitting a bug report
at https://mariadb.org/jira

Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall mariadb
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

MySQL is configured to only allow connections from localhost by default

To restart mariadb after an upgrade:
  brew services restart mariadb
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/mariadb/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql
==> Summary
  /opt/homebrew/Cellar/mariadb/10.6.4: 898 files, 170.1MB
==> Running `brew cleanup mariadb`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

(2)安装后我重启服务器

 $ brew services restart mariadb
Stopping `mariadb`... (might take a while)
==> Successfully stopped `mariadb` (label: homebrew.mxcl.mariadb)
==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)

(3) 我尝试登录数据库

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

任何建议将不胜感激。

4

0 回答 0