Programing

OS X Yosemite / El Capitan에서 시작시 MySQL을 자동로드하는 방법

lottogame 2020. 10. 16. 06:59
반응형

OS X Yosemite / El Capitan에서 시작시 MySQL을 자동로드하는 방법


OS X를 업그레이드 한 후 MySQL 설치가 시작시로드를 중지했습니다.

MySQL 연습 에서는 다음과 같이 말합니다.

"시작 항목 설치는 변수 MYSQLCOM = -YES-를 시스템 구성 파일 / etc / hostconfig에 추가합니다. MySQL의 자동 시작을 비활성화하려면이 변수를 MYSQLCOM = -NO-로 변경하십시오."

그래서 그 파일을 열면 다음과 같이 표시됩니다.

# This file is going away 
AFPSERVER=-NO- 
AUTHSERVER=-NO-
TIMESYNC=-NO-
QTSSERVER=-NO-
MYSQLCOM=-YES-

나는 OSX 개발자가 추가되었다고 가정 # This file is going away하지만 확실하지 않습니다.

그렇다면 OSX Yosemite에서 시작할 때 MySQL을 시작하는 적절한 방법은 무엇입니까?


이것이 수정 된 것입니다.

먼저 새 파일을 만듭니다. /Library/LaunchDaemons/com.mysql.mysql.plist

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true />
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/mysql/bin/mysqld_safe</string>
      <string>--user=mysql</string>
    </array>        
  </dict>
</plist>

그런 다음 권한을 업데이트하고 다음에 추가하십시오 launchctl.

sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist

homebrew 를 통해 mysql을 설치했다면 launchd로그인 때 다음과 같이 mysql을 시작할 수 있습니다 .

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents

수락 된 답변은 내 MySQL 서버를 자동 시작하는 데 작동하지 않았습니다 (실제로 내 기본 설정 창은 활성화 된 동안 열려고 할 때마다 시스템 기본 설정이 충돌했습니다). MySQL 5.6 핸드북 의 지침을 따랐고 마침내 다시 자동 시작됩니다! /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist다음 내용으로 파일 만듭니다 .

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>             <string>com.oracle.oss.mysql.mysqld</string>
    <key>ProcessType</key>       <string>Interactive</string>
    <key>Disabled</key>          <false/>
    <key>RunAtLoad</key>         <true/>
    <key>KeepAlive</key>         <true/>
    <key>SessionCreate</key>     <true/>
    <key>LaunchOnlyOnce</key>    <false/>
    <key>UserName</key>          <string>_mysql</string>
    <key>GroupName</key>         <string>_mysql</string>
    <key>ExitTimeOut</key>       <integer>600</integer>
    <key>Program</key>           <string>/usr/local/mysql/bin/mysqld</string>
    <key>ProgramArguments</key>
        <array>
            <string>/usr/local/mysql/bin/mysqld</string>
            <string>--user=_mysql</string>
            <string>--basedir=/usr/local/mysql</string>
            <string>--datadir=/usr/local/mysql/data</string>
            <string>--plugin-dir=/usr/local/mysql/lib/plugin</string>
            <string>--log-error=/usr/local/mysql/data/mysqld.local.err</string>
            <string>--pid-file=/usr/local/mysql/data/mysqld.local.pid</string>
            <string>--port=3306</string>
        </array>
    <key>WorkingDirectory</key>  <string>/usr/local/mysql</string>
</dict>
</plist>

그리고 파일을 만든 후 다음 명령을 실행하십시오.

cd /Library/LaunchDaemons
sudo chown root:wheel com.oracle.oss.mysql.mysqld.plist 
sudo chmod o-w com.oracle.oss.mysql.mysqld.plist 
sudo launchctl load -F com.oracle.oss.mysql.mysqld.plist

내 Mac은 El Capitan에서 실행됩니다. 양조를 통해 설치된 MySQL.

mysql.server status 

해결해야 할 몇 가지 문제가 있다고 말했습니다.

ERROR! MySQL is not running, but PID file exists

디렉토리 에서 homebrew.mxcl.mysql.plist파일을 /usr/local/Cellar/mysql/x.x.x/찾아서 복사했습니다./Library/LaunchDaemons/

sudo cp homebrew.mxcl.mysql.plist /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

필요한 모든 권한을 설정합니다.

sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.mysql.plist

Justin이 설명한 조언의 일부 사용


There is a bash script by MacMiniVault, which will do this for you - and install MySQL as well. There is also an article which describes the process.

It is suggested in the article to pipe the script straight into Terminal and run it, but as this has some serious security implications, it is a better idea to download and inspect the script before running it locally.

Note: This reply has been reworked in response to comments about the security implications of following the instructions in the aforementioned article. It is generally a bad idea to pipe a shell script from an unknown source directly to bash. Also, if you don't understand the script or trust the author, don't use it.

참고URL : https://stackoverflow.com/questions/26476391/how-to-auto-load-mysql-on-startup-on-os-x-yosemite-el-capitan

반응형