我安装mysql时缺少文件

时间:2020-06-07 14:27:46

标签: mysql macos terminal homebrew

我尝试过几次安装/卸载mysql。 我仍然有相同的错误消息:

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

实际上,tmp上没有mysql.sock

这里有个例子:

brew install mysql

然后我得到

Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.19_1.catalina.bottle.tar.gz
Already downloaded: /Users/myname/Library/Caches/Homebrew/downloads/d8a3b1d8709c6ed74cfe9b16bb61a8770b811043a3b3e5791ec615beab5f41ec--mysql-8.0.19_1.catalina.bottle.tar.gz
==> Pouring mysql-8.0.19_1.catalina.bottle.tar.gz
==> Caveats
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

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
?  /usr/local/Cellar/mysql/8.0.19_1: 286 files, 288.8MB

所以我跑

sudo mysql.server start   

我知道了

Starting MySQL
.Logging to '/usr/local/var/mysql/MacBook-Pro-de-Samantha.local.err'.
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro-de-myname.local.pid).

所以我

ERROR! MySQL server PID file could not be found!

/ usr / local / var / mysql上也没有 MacBook-Pro-de-myname.local.pid

我也很想动

mysql_secure_installation

然后输入root用户的密码。

我总是收到此错误消息:

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

我已经尝试使用来自dev.mysql.com的本地软件包在macOS上安装MySQL,但是仍然存在相同的问题。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我刚刚在我的Mojave盒子上尝试过brew install mysql,对我来说效果很好。

安装日志:

==> Pouring mysql-8.0.19_1.mojave.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.19_1/bin/mysqld --initialize-insecure --user=rchen --basedir=/usr/local/Cellar/mysql/8.0.19_1 --datadir=/
==> Caveats
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

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
?  /usr/local/Cellar/mysql/8.0.19_1: 286 files, 288.8MB

运行日志

$ brew services start mysql
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 48, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 825 (delta 18), reused 16 (delta 3), pack-reused 777
Receiving objects: 100% (825/825), 231.32 KiB | 4.36 MiB/s, done.
Resolving deltas: 100% (335/335), done.
Tapped 1 command (40 files, 310.6KB).
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

$ mysql_secure_installation

$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.

New password:

Re-enter new password:
Sorry, passwords do not match.

New password:

Re-enter new password:

Estimated strength of the password: 25