标签:
用brew安装mysql
brew install mysql
开机启动
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
2.查看配置文件引用的路径
mysqld --help --verbose | more
通过这命令,可以看出mysql默认调用的配置文件路径:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
然后,我们搜索一下目录下的文件是否已经创建:
cd / find . -name "my.cnf"
3. 创建配置文件
通常这几个路径都是没有创建配置文件的,我们自己创建一下。
先找出我们安装的mysql的配置样例文件,在安装文件中的support-files文件夹中:
ls $(brew --prefix mysql)/support-files/my-*
复制到引用目录:
cp /usr/local/opt/mysql/support-files/my-default.cnf /etc/my.cnf
然后就可以按自己需求修改配置了
4.重新mysql, unload 是关闭, load是启动
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
为了文件管理可以把命令alias下:
vim ~/.bash_aliases
输入以下内容,保存
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart=‘mysql.stop && mysql.start‘
保存后
echo "[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases" >> ~/.bash_profile source ~/.bash_profile
这样,直接调用命令
mysql.start
mysql.stop
mysql.restart
就可以控制开启,关闭和重启了
标签:
原文地址:http://my.oschina.net/jiec/blog/518590