mac 設置mysql開機自啟動


1、編輯一個mysql啟動文件。

在終端里面輸入:    

sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist 

2、輸入啟動文件內容:

<?xml version="1.0" encoding="UTF-8"?>    
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">    
<plist version="1.0">    
  <dict>    
    <key>KeepAlive</key>    
    <true/>    
    <key>Label</key>    
    <string>com.mysql.mysqld</string>    
    <key>ProgramArguments</key>    
    <array>    
    <string>/usr/local/Cellar/mysql/5.7.20/bin/mysqld_safe</string>    
    <string>--user=root</string>    
    </array>      
  </dict>    
</plist>

上面xml中的 /usr/local/Cellar/mysql/5.7.20/bin/mysqld_safe 為我的mysql所在目錄。

這個是通過homebrew下載的mysql。

官方下載的路徑為 /usr/local/mysql/bin/mysqld_safe

3、加載這個啟動文件

在終端里輸入:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist  

這樣你就會發現mysql成功啟動了。

ps -aef | grep mysql

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM