2011-09-06 174 views
1

我正在與MAMP包中包含的SQL服務器一起工作。我想設置我的電腦,以便SQL服務器在我啓動時自動啓動。有誰知道最簡單的方法來做到這一點?如何在系統啓動時自動啓動MAMP sql server

很多,很多的感謝,

D.

UPDATE

當我嘗試使用Macmade建議LaunchDaemon文件,下面,我得到以下錯誤:

110906 19:52:05 mysqld_safe Starting mysqld daemon with databases from /Applications/MAMP/db/mysql 
110906 19:52:05 [Warning] Setting lower_case_table_names=2 because file system for /Applications/MAMP/db/mysql/ is case in$ 
110906 19:52:05 [Note] Plugin 'FEDERATED' is disabled. 
^G/Applications/MAMP/Library/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13) 
110906 19:52:05 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 
110906 19:52:05 InnoDB: The InnoDB memory heap is disabled 
110906 19:52:05 InnoDB: Mutexes and rw_locks use GCC atomic builtins 
110906 19:52:05 InnoDB: Compressed tables use zlib 1.2.3 
110906 19:52:05 InnoDB: Initializing buffer pool, size = 128.0M 
110906 19:52:05 InnoDB: Completed initialization of buffer pool 
110906 19:52:05 InnoDB: Operating system error number 13 in a file operation. 
InnoDB: The error means mysqld does not have the access rights to 
InnoDB: the directory. 
InnoDB: File name ./ibdata1 
InnoDB: File operation call: 'open'. 
InnoDB: Cannot continue operation. 
110906 19:52:05 mysqld_safe mysqld from pid file /Applications/MAMP/db/mysql/Doyuen-Kos-Mac-Pro.local.pid ended 

在此之後,我查找了一些MAMP目錄,並找到了一個名爲startMysql.sh的腳本。當我從命令行運行它時,它會啓動sql服務器。完善。如果沒有可能的話,我也嘗試將它放入LaunchDaemon文件中。

<?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> 
    <false/> 
    <key>Label</key> 
    <string>mysql</string> 
    <key>ProgramArguments</key> 
    <array> 
     <string>/Applications/MAMP/bin/start.sh</string> 
    </array> 
    <key>RunAtLoad</key> 
    <true/> 
</dict> 
</plist> 

這也沒有工作。另外,奇怪的是,它似乎沒有在控制檯應用程序中產生任何類型的消息。

我仍然卡住了。有人有主意嗎?

回答

-1

我只是想出了一個可能的解決了這個問題。事實證明,MAMP的付費版本MAMP Pro具有簡單的一鍵式功能,可將系統配置爲在啓動時啓動SQL服務器。所以,掏出$ 50美元購買付費版本是實現這一目標的一種方式。這不是我希望的那種解決方案,但它完成了工作。

2

您可能需要一個LaunchDaemon文件。

在/ Library/LaunchDaemons /目錄中創建一個名爲whatever.plist的文件,並放置以下內容。

注意,權限必須是:根:車輪/ 644

<?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> 
    <false/> 
    <key>Label</key> 
    <string>mysql</string> 
    <key>ProgramArguments</key> 
    <array> 
     <string>/path/to/mysql/bin/mysqld_safe</string> 
     <string>--user=_mysql</string> 
    </array> 
    <key>RunAtLoad</key> 
    <true/> 
</dict> 
</plist> 
+1

Macmade,謝謝*很*的答案。不幸的是,這並不奏效(請參閱上面的編輯)。任何其他想法? –

3

打開文本編輯或MAC純文本編輯器,在它

對於Apache

<?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>Label</key> 
    <string>info.mamp.start.apache</string> 
    <key>ProgramArguments</key> 
    <array> 
     <string>/Applications/MAMP/Library/bin/apachectl</string> 
     <string>start</string> 
    </array> 
    <key>RunAtLoad</key> 
    <true/> 
    </dict> 
</plist> 

然後爲MySQL創建另一個文件粘貼此

<?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>Label</key> 
    <string>info.mamp.start.mysql</string> 
    <key>ProgramArguments</key> 
    <array> 
     <string>/Applications/MAMP/Library/bin/mysqld_safe</string> 
     <string>--port=3306</string> 
     <string>--socket=/Applications/MAMP/tmp/mysql/mysql.sock</string> 
     <string>--lower_case_table_names=0</string> 
     <string>--pid-file=/Applications/MAMP/tmp/mysql/mysql.pid</string> 
     <string>--log-error=/Applications/MAMP/logs/mysql_error_log</string> 
    </array> 
    <key>RunAtLoad</key> 
    <true/> 
    <key>UserName</key> 
    <string>YOUR_USERNAME</string> 
    </dict> 
</plist> 

務必更換「YOUR_USERNAME 「用你的賬戶的用戶名。

將此文件另存爲(或將文件移動到)/Library/LaunchDaemons/info.mamp.start.apache.plist和/Library/LaunchDaemons/info.mamp.start.mysql.plist。

文件夾保存這是/庫/ LaunchDaemons/

打開終端,輸入

坎德拉/庫/ LaunchDaemons/ 須藤CHOWN根:輪info.mamp.start.apache.plist sudo chown root:wheel info.mamp.start.mysql。plist

完成。重新啓動你的Mac

Ref:http://stringfoo.com/2008/08/25/tutorial-launching-mamp-silently-on-startup/

+0

此方法可以工作。 – tonix

相關問題