Mac mysql 自动启动

Mac mysql 5.7.x 设置服务开机自启动

  1. 编辑一个mysql启动文件

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

<?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/opt/mysql@5.7/bin/mysql</string>  
    <string>--user=root</string>  
    </array>    
  </dict>  
</plist>
  1. 加载这个启动文件

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

这样你就会发现mysql成功启动了。

ps -aef | grep mysql


Demi_YuHongJun

Demi的随笔和技术空间