Manage background services with macOS' launchctl(1) daemon manager.
If sudo is passed, operate on /Library/LaunchDaemons (started at boot). Otherwise, operate on ~/Library/LaunchAgents (started at login).
[sudo] brew services [list]: List all managed services for the current user (or root).
[sudo] brew services run (formula|--all): Run the service formula without registering to launch at login (or boot).
[sudo] brew services start (formula|--all): Start the service formula immediately and register it to launch at login (or boot).
[sudo] brew services stop (formula|--all): Stop the service formula immediately and unregister it from launching at login (or boot).
[sudo] brew services restart (formula|--all): Stop (if necessary) and start the service formula immediately and register it to launch at login (or boot).
[sudo] brew services cleanup: Remove all unused services.
--all Run subcommand on all services. -d, --debug Display any debugging information. -q, --quiet Make some output more quiet. -v, --verbose Make some output more verbose. -h, --help Show this message.
brew info
描述是 「Display brief statistics for your Homebrew installation.」非常有用! 例如下面 brew info mongodb-community 显示了启动 mongo 服务的命令; 另外,对于如未安装的 musql 服务也可显示相关信息。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ brew info mongodb-community mongodb/brew/mongodb-community: stable 4.4.4 High-performance, schema-free, document-oriented database https://www.mongodb.com/ /usr/local/Cellar/mongodb-community/4.4.3 (11 files, 156.8MB) * Built from source on 2021-03-18 at 14:34:09 From: https://github.com/mongodb/homebrew-brew/blob/HEAD/Formula/mongodb-community.rb ==> Dependencies Recommended: mongodb-database-tools ✘ ==> Options --without-mongodb-database-tools Build without mongodb-database-tools support ==> Caveats To have launchd start mongodb/brew/mongodb-community now and restart at login: brew services start mongodb/brew/mongodb-community Or, if you don't want/need a background service you can just run: mongod --config /usr/local/etc/mongod.conf
$ brew info mysql mysql: stable 8.0.23 (bottled) Open source relational database management system https://dev.mysql.com/doc/refman/8.0/en/ Conflicts with: mariadb (because mysql, mariadb, and percona install the same binaries) percona-server (because mysql, mariadb, and percona install the same binaries) Not installed From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/mysql.rb License: GPL-2.0-only ==> Dependencies Build: cmake ✘ Required: openssl@1.1 ✘, protobuf ✘ ==> Caveats We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run: mysql -uroot
To have launchd start mysql now and restart at login: brew services start mysql Or, if you don't want/need a background service you can just run: mysql.server start