修改用brew安裝的mysql配置

來源:互聯網
上載者:User

標籤:

  1. 用brew安裝mysql

brew install mysql

  開機啟動

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgentslaunchctl 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.plistlaunchctl 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

  就可以控制開啟,關閉和重啟了


修改用brew安裝的mysql配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.