brew install mysql on macOS
我正在尝试使用Homebrew by
一切顺利,我也成功了
但是,当我尝试使用以下命令连接到服务器时:
我明白了:
1 2 |
我也试过访问
但无论是否有密码都无效。
这是在全新机器上的全新安装,据我所知,必须可以在没有root密码的情况下访问新安装。 我也尝试过:
但我也明白了
我认为已经安装了旧版本的mysql,最终可能会处于这个位置。我遇到了同样的问题,上述解决方案都没有对我有用。我这样解决了:
使用brew的
更新了plist的字符串。另请注意,您的备用安全脚本目录将基于您要安装的MySQL版本。
一步步:
1 2 3 4 5 6 7 8 9 | brew remove mysql brew cleanup launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist sudo rm -rf /usr/local/var/mysql |
然后我从头开始:
运行brew建议的命令:(见下面注释)
使用
使用备用安全脚本:
按照brew包脚本输出中的
1 2 3 4 5 | #start launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist #stop launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist |
繁荣。
希望有人帮助!
注意:
请注意第二个:评论者说不需要第2步。我不想测试它,所以YMMV!
以下是结合从Mac上删除所??有MySQL然后安装它的详细说明以上所述的Brew Way as Sedorner:
根据The Tech Lab完全删除MySQL
-
ps -ax | grep mysql -
停止并
kill 任何MySQL进程 -
sudo rm /usr/local/mysql -
sudo rm -rf /usr/local/var/mysql -
sudo rm -rf /usr/local/mysql* -
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist - <5233>
-
sudo rm -rf /Library/PreferencePanes/My* -
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist -
编辑
/etc/hostconfig 并删除MYSQLCOM=-YES- 行 -
rm -rf ~/Library/PreferencePanes/My* -
sudo rm -rf /Library/Receipts/mysql* -
sudo rm -rf /Library/Receipts/mysql* -
sudo rm -rf /private/var/db/receipts/*mysql* -
sudo rm -rf /tmp/mysql* -
尝试运行
mysql ,它应该不起作用
Brew从此StackOverflow答案中为每个用户Sedorner安装MySQL
-
brew doctor 并修正任何错误 -
brew remove mysql -
brew cleanup -
brew update -
brew install mysql -
unset TMPDIR -
mysql_install_db --verbose --user= WHOAMI--basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp -
mysql.server start -
运行Brew建议的命令,将MySQL添加到
launchctl ,以便它在启动时自动启动
一帆风顺。
有同样的问题。似乎设置说明或正在创建的初始表有问题。这就是我在我的机器上运行mysqld的方法。
如果mysqld服务器已在Mac上运行,请先停止它:
使用以下命令启动mysqld服务器,该命令允许任何人以完全权限登录。
然后运行
现在,如果您终止mysqld_safe的运行副本并在没有skip-grant-tables选项的情况下再次启动它,您应该能够使用
如果brew安装了MySQL 5.7,则该过程与以前的版本略有不同。
要重置root密码,请执行以下操作:
1 2 |
临时密码将打印到控制台,它只能用于更新root密码:
1 2 |
我刚才遇到了同样的问题。如果你
事实证明我没有为我创建任何帐户。当我在运行
好的,我有同样的问题并解决了它。出于某种原因,当使用Homebrew安装mysql时,mysql_secure_installation脚本不能正常工作,所以我手动完成了。在CLI上输入:
1 | mysql -u root |
这应该让你进入mysql。现在执行以下操作(取自mysql_secure_installation):
1 2 3 4 5 6 |
现在退出并返回到mysql:
如果已经安装了mysql
完全停止mysql。
删除文件。上面的说明很好。我要补充一下:
安装
希望你有自制软件。如果没有,请下载它。
我喜欢以root身份运行brew,但我不认为你必须这样做。编辑2018:您不能再以root身份运行brew
然后
brew info mysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | mysql: stable 5.6.12 (bottled) http://dev.mysql.com/doc/refman/5.6/en/ Conflicts with: mariadb, mysql-cluster, percona-server /usr/local/Cellar/mysql/5.6.12 (9363 files, 353M) * Poured from bottle From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/mysql.rb ==> Dependencies Build: cmake ==> Options --enable-debug Build with debug support --enable-local-infile Build with local infile loading support --enable-memcached Enable innodb-memcached support --universal Build a universal binary --with-archive-storage-engine Compile with the ARCHIVE storage engine enabled --with-blackhole-storage-engine Compile with the BLACKHOLE storage engine enabled --with-embedded Build the embedded server --with-libedit Compile with editline wrapper instead of readline --with-tests Build with unit tests ==> Caveats A"/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. To connect: mysql -uroot To reload mysql after an upgrade: launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist |
mysql.service启动
1 | . ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid). |
或者mysql -u root
1 | ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) |
我正在寻找一段时间的解决方案,但我无法解决我的问题。我在stackoverflow.com上尝试了几个解决方案,但没有这个帮助我。
TL; DR
使用Brew安装后,MySQL服务器可能无法运行。如果您不希望MySQL作为后台服务运行,请尝试
全文:
我刚刚在运行Sierra的新MacBook Pro上安装了MySQL(稳定版)5.7.17,并在运行
1 2 3 4 |
说什么?
根据Brew的安装信息,
这是MySQL 5.7的更新
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | bash --version GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin17.0.0) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. #======================================== brew --version Homebrew 1.7.6 Homebrew/homebrew-core (git revision eeb08; last commit 2018-09-27) Homebrew/homebrew-cask (git revision c9f62; last commit 2018-09-27) #======================================== mysql --version mysql Ver 14.14 Distrib 5.7.23, for osx10.13 (x86_64) using EditLine wrapper #======================================== system_profiler SPSoftwareDataType Software: System Software Overview: System Version: macOS 10.13.3 (17D47) Kernel Version: Darwin 17.4.0 Boot Volume: Macintosh HD Boot Mode: Normal Computer Name: EdisonMacHomeBj User Name: Edison (edison) Secure Virtual Memory: Enabled System Integrity Protection: Disabled Time since boot: 6 days 23:13 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | brew remove mysql@5.7 brew cleanup mv /usr/local/var/mysql /usr/local/var/mysql.bak brew install mysql@5.7 rm -rf /usr/local/var/mysql #======================================== mysqld --initialize 2018-09-28T04:54:06.526061Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-09-28T04:54:06.542625Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive 2018-09-28T04:54:07.096637Z 0 [Warning] InnoDB: New log files created, LSN=45790 2018-09-28T04:54:07.132950Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2018-09-28T04:54:07.196824Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 87cf2f10-c2da-11e8-ac2d-ba163df10130. 2018-09-28T04:54:07.224871Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2018-09-28T04:54:07.366688Z 0 [Warning] CA certificate ca.pem is self signed. 2018-09-28T04:54:07.457954Z 1 [Note] A temporary password is generated for root@localhost: kq3K=JR8;GqZ #======================================== mysql_secure_installation -uroot -p"kq3K=JR8;GqZ" mysql_secure_installation: [Warning] Using a password on the command line interface can be insecure. Securing the MySQL server deployment. The existing password for the user account root has expired. Please set a new password. New password: Re-enter new password: VALIDATE PASSWORD PLUGIN 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 plugin? Press y|Y for Yes, any other key for No: n Using existing password for root. Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Re-enter new password: By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n ... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n ... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done! |
当使用brew与最新版本的mysql和yosemite时,上述答案(或我在其他地方看到的任何答案中的任何一个)都没有为我工作。我最终通过brew安装了一个不同的mysql版本。
通过说(例如)指定旧版本
1 | brew install mysql56 |
为我工作。希望这有助于某人。这是一个令人沮丧的问题,我觉得我永远陷入困境。
尝试给予Grant权限命令mysql
Mysql的"Base-Path"存储在
例如,改变这个:
1 2 | [mysqld] basedir=/Users/3st/homebrew/Cellar/mysql/5.6.13 |
指向新版本:
1 2 | [mysqld] basedir=/Users/3st/homebrew/Cellar/mysql/5.6.19 |
用以下命令重启mysql:
1 | mysql.server start |
我尝试重新启动mysql后遇到了同样的问题。
为方便起见,我在.profile中使用以下两个别名
1 2 | alias mysql-stop='launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist' alias mysql-start='launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist' |
在停止mysql然后尝试重新启动后,我遇到了你遇到的问题。我查看了launchctl加载,它报告了"没有发现加载"错误。
快速搜索后我发现了这个..
http://www.daveoncode.com/2013/02/01/solve-mac-osx-launchctl-nothing-found-to-load-error/
所以我更新了我的
1 |
这解决了我可能对您有用的问题。