Mac上通过 brew 安装MySQL及其问题
2017-12-06 16:14
956 查看
一、环境和安装
macOS 版本:10.13.1Mysql 版本:
mysql Ver 14.14 Distrib 5.7.20, for osx10.13 (x86_64) using EditLine wrapper
使用 brew 安装 MySQL:
brew install mysql brew tap homebrew/services brew services start mysql
其他命令:
# 获取 service 列表 brew services list # 重启 mysql 服务 brew services restart mysql # 停止 mysql 服务 brew services stop mysql
安装参考:Install MySQL on macOS Sierra
brew services 官网:homebrew-services
二、碰到的问题
1、无法连接
描述:使用 Navicat 或者是命令行都无法连接,均提示用户名/密码错误。
ERROR 1045 (28000) Access denied for user 'root'@'localhost' (using password: NO)
解决方法:
使用不要密码登录:
sudo mysqld_safe --skip-grant-tables &
再使用下面脚本重新设置下数据库的 root 密码:
UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass') WHERE User = 'root' AND Host = 'localhost'; FLUSH PRIVILEGES;
2、日志里面出现mysql 无法重启启动的错误日志
日志详情:Dec 6 01:36:35 --- last message repeated 1 time --- Dec 6 01:36:35 s01 com.apple.xpc.launchd[1] (homebrew.mxcl.mysql[18960]): Service exited with abnormal code: 1 Dec 6 01:36:35 s01 com.apple.xpc.launchd[1] (homebrew.mxcl.mysql): Service only ran for 0 seconds. Pushing respawn out by 10 seconds. Dec 6 01:36:45 s01 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system): Session adoption is only allowed in user domains. Dec 6 01:36:45 --- last message repeated 1 time --- Dec 6 01:36:45 s01 com.apple.xpc.launchd[1] (homebrew.mxcl.mysql[19029]): Service exited with abnormal code: 1 Dec 6 01:36:45 s01 com.apple.xpc.launchd[1] (homebrew.mxcl.mysql): Service only ran for 0 seconds. Pushing respawn out by 10 seconds. Dec 6 01:36:55 s01 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system): Session adoption is only allowed in user domains. Dec 6 01:36:55 --- last message repeated 1 time --- Dec 6 01:36:55 s01 com.apple.xpc.launchd[1] (homebrew.mxcl.mysql[19098]): Service exited with abnormal code: 1 Dec 6 01:36:55 s01 com.apple.xpc.launchd[1] (homebrew.mxcl.mysql): Service only ran for 0 seconds. Pushing respawn out by 10 seconds. Dec 6 01:37:06 s01 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.system): Session adoption is only allowed in user domains.
解决:
我查了下系统跑的有 mysql 进程(
ps -e | grep mysql),也就是说出现了重复创建 mysql 服务。
查看 macos 的自启动服务列表:
ll ~/Library/LaunchAgents ll /Library/LaunchDaemons ll /Library/LaunchAgents
发现有重复的 mysql 服务,删除掉重复的就是。
因为使用的是 brew services 方式运行,所以可以通过
brew services list来获取正在运行的,把另外一个删除了就行。
三、最后说2句
推荐使用 docker 方式,之前我使用的 mssql docker 版本就好安装的多。用了这么久,mssql docker 偶尔会出现莫名其妙的闪退,而且也没有发现日志,疑惑!!!!。
相关文章推荐
- mac 通过brew 安装的mysql启动失败解决方案
- MAC 安装mysql 5.7 以上问题解决,MAC安装brew所遇问题解决
- mac下使用brew安装svn javahl的问题
- mac下mysql安装出现的问题总结
- Mac 下通过dmg包安装mysql
- mac中安装mysql-python遇到的问题
- mac安装mysql-python遇到的问题
- mac node 安装mysql-libmysqlclient 问题
- mac eclipse javaHL not available解决方案(brew 安装并解决被墙问题)
- MAC 通过brew安装软件
- Mac下通过 brew 安装不同版本的php
- Mac下通过Homebrew安装配置MySQL
- mac下brew 安装mysql
- MAC10.10下安装mysqlserver的问题(由于mysqlserver现在才支持到10.9而已,所以会出问题)
- Mac OS X 通过brew安装命令行工具
- mac下安装xampp后mysql无法启动的问题
- linux下mysql 安装冲突问题及其数据库导入导出
- CentOS7下通过rpm方式安装MySQL及插入中文问题解决 [原创]
- Linux下通过yum来安装 mysql 5.1,以及以前的旧版本(因服务器网络问题,安装后无法连接,无法验证正确性)
- Mac上使用命令行安装brew,并通过brew安装Ant等工具