code

Mac OS X Yosemite / El Capitan에서 MySQL 서버 자동 시작

codestyles 2020. 9. 24. 07:51
반응형

Mac OS X Yosemite / El Capitan에서 MySQL 서버 자동 시작


시작할 때 MySQL 서버를 자동으로 시작하고 싶습니다. 이것은 Mavericks에서 가능했지만 Yosemite에서는 작동하지 않는 것 같습니다.

편집 : El Capitan에서도 작동하는 것 같습니다.

여기에 이미지 설명 입력


@dcc는 매우 가까웠습니다. 이것은 MySQL이 Yosemite에서 다시 자동 시작되는 방법입니다.

com.mysql.mysql.plist에서 /Library/LaunchDaemons:

<?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/mysql/bin/mysqld_safe</string>
    <string>--user=mysql</string>
    </array>
  </dict>
</plist>

또한 이 답변을 기반으로 권한을 변경했습니다.

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

추가 사항이 있으면 아래에 공유하십시오!


@revaxarts 지시를 따르고 명령을 실행하려고 할 때

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

오류가 발생했습니다.

/Library/LaunchDaemons/com.mysql.mysql.plist : 잘못된 속성 목록

잠시 머리를 긁은 후 맨 위에있는 DOCTYPE DTD 선언을 제거하면 오류가 사라지고 mySQL 서버를 다시 시작할 때 실제로 실행 중이라는 것을 알았습니다.

따라서 내 XML은 다음과 같습니다.

<?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>

homebrew와 함께 mysql설치 한 경우를 입력하여 자동 시작 방법에 대한 지침을 얻을 수 있습니다 brew info mysql.

예를 들어 내 컴퓨터의 출력은 다음과 같습니다.

To have launchd start mysql at login:
  ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

만들기 /Library/LaunchDaemons/com.mysql.mysql.plist및 다음 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>
        </true>
    </dict>
</plist>

그런 다음 새로 생성 된 plist 파일을로드합니다.

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

이 도움말은 잘못된 오류 문제를 해결하는 데 도움이됩니다. 아래에서 사용한 수정 된 plist.

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/mysql/bin/mysqld_safe</string> 
<string>--user=mysql</string> 
</array> 
</dict> 
</plist>

None of the other provided answers worked to auto-start my MySQL server. I followed the instructions from the MySQL 5.6 handbook and it finally auto-starts again! Create the file /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist with the following content:

<?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>

And run the following commands after creating the file:

cd /Library/LaunchDaemons
sudo launchctl load -F com.oracle.oss.mysql.mysqld.plist

When I used the plist suggested in earlier answers, I changed the user to _mysql for my system, but the "Stop MySQL Server" button in the MySQL preference pane no longer worked. The KeepAlive key will cause the process to launch again immediately after the Stop button is pressed. I used the key RunAtLoad to get it to just start on reboot, but allow the button in the pane to continue working.

<?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>RunAtLoad</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>

Then, as in the other answers, ran:

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

이제 MySQL은 다시 시작할 때 시작되지만 시스템 환경 설정의 MySQL 패널은 계속 작동합니다. El Capitan, 10.11.2를 실행 중입니다.

참고 URL : https://stackoverflow.com/questions/26461173/autostart-mysql-server-on-mac-os-x-yosemite-el-capitan

반응형