gpt4 book ai didi

mysql - 如何在系统启动时自动启动 MAMP sql server

转载 作者:行者123 更新时间:2023-11-29 04:55:01 27 4
gpt4 key购买 nike

我正在使用 MAMP 包中包含的 SQL 服务器进行一些工作。我想设置我的计算机,以便 SQL 服务器在我启动时自动启动。有谁知道实现这一目标的最简单方法?

非常感谢,

D.

更新

当我尝试使用下面 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 server。完美的。如果它可能起作用,我也尝试将其放入 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>

这也没有用。此外,奇怪的是,它似乎没有在控制台应用程序中产生任何类型的消息。

我还是卡住了。有人有什么想法吗?

最佳答案

在 mac 中打开 Textedit 或纯文本编辑器,将其粘贴到其中

对于 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。

保存这个的文件夹是/Library/LaunchDaemons/

打开终端,输入

cd/Library/LaunchDaemons/sudo chown root:wheel info.mamp.start.apache.plistsudo chown root:wheel info.mamp.start.mysql.plist

完成。重启你的 Mac

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

关于mysql - 如何在系统启动时自动启动 MAMP sql server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7326713/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com