Launching MariaDB on Boot on macOS (10.15 Catalina)

I've installed MariaDB 10.5.11 on a freshly upgraded 10.15.7 Mac. I have a launchd script that is supposed to start up the database server on system boot. But it doesn't work. It tries, I can confirm that. But the database server just won't launch when run in this way.

But what's crazy is that if I run the same exact command with sudo in the terminal, the database server starts right up every time.

I installed via HomeBrew and tried using their startup plist. I also tried using my own. They are essentially identical. They do try to launch the server but it immediately shuts down. It does give me errors but they're not very helpful errors.

This is what I get when launchd tries and fails to start up the server on boot:

  • 210709 04:21:43 mysqld_safe Starting mariadbd daemon with databases from /usr/local/var/mysql
  • 2021-07-09 4:21:44 0 [Note] /usr/local/opt/mariadb/bin/mariadbd (mysqld 10.5.11-MariaDB) starting as process 486 ...
  • 2021-07-09 4:21:45 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
  • /usr/local/opt/mariadb/bin/mariadbd: Please consult the Knowledge Base to find out how to run mysqld as root!
  • 2021-07-09 4:21:45 0 [ERROR] Aborting
  • 210709 04:21:45 mysqld_safe mysqld from pid file /usr/local/var/mysql/Home-Server.local.pid ended

I have tried adding a user=_mysql attribute to the startup command, and then in a /etc/my.cnf file, but neither of those tricks solved the problem.

I have had similar "it just won't start up" problems in the past, but they were solved by the database's data folder not being owned by the database user. That is not the case here, I've double triple checked that.

Note that launchd scripts in /Library/LaunchDaemons are run as root. Meanwhile, when I use sudo to manually run the startup command from the terminal, this is what I get in the error log. Starts off the same then it simply doesn't fail for unknown reason:

  • 210709 04:23:51 mysqld_safe Starting mariadbd daemon with databases from /usr/local/var/mysql
  • 2021-07-09 4:23:51 0 [Note] /usr/local/opt/mariadb/bin/mariadbd (mysqld 10.5.11-MariaDB) starting as process 1046 ...
  • 2021-07-09 4:23:51 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
  • 2021-07-09 4:23:51 0 [Note] InnoDB: Uses event mutexes
  • 2021-07-09 4:23:51 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
  • 2021-07-09 4:23:51 0 [Note] InnoDB: Number of pools: 1
  • 2021-07-09 4:23:51 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
  • 2021-07-09 4:23:51 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
  • 2021-07-09 4:23:51 0 [Note] InnoDB: Completed initialization of buffer pool
  • 2021-07-09 4:23:51 0 [Note] InnoDB: 128 rollback segments are active.
  • 2021-07-09 4:23:52 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  • 2021-07-09 4:23:52 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  • 2021-07-09 4:23:52 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  • 2021-07-09 4:23:52 0 [Note] InnoDB: 10.5.11 started; log sequence number 16768487; transaction id 145097
  • 2021-07-09 4:23:52 0 [Note] Plugin 'FEEDBACK' is disabled.
  • 2021-07-09 4:23:52 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
  • 2021-07-09 4:23:52 0 [Note] Server socket created on IP: '::'.
  • 2021-07-09 4:23:52 0 [Note] InnoDB: Buffer pool(s) load completed at 210709 4:23:52
  • 2021-07-09 4:23:52 0 [Note] Reading of all Master_info entries succeeded
  • 2021-07-09 4:23:52 0 [Note] Added new Master_info '' to hash table
  • 2021-07-09 4:23:52 0 [Note] /usr/local/opt/mariadb/bin/mariadbd: ready for connections.
  • Version: '10.5.11-MariaDB' socket: '/tmp/mysql.sock' port: 3306 Homebrew

So at this point, you probably want to know what command I'm actually running to get this server going? This is what I'm running manually from the terminal (which is successful):

  • sudo /usr/local/opt/mariadb/bin/mysqld_safe --datadir=/usr/local/var/mysql

This is my startup script, /Library/LaunchDaemons/home-server.mariadb.plist (permissions on this file are also correct and it is running and trying to run the database)

  • <?xml version="1.0" encoding="UTF-8"?>
  • <!DOCTYPE plist PUBLIC "-AppleDTD PLIST 1.0EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  • <plist version="1.0">
  • <dict>
  • <key>Label</key>
  • <string>home-server.mariadb</string>
  • <key>ProgramArguments</key>
  • <array>
  • <string>/usr/local/opt/mariadb/bin/mysqld_safe</string>
  • <string>--datadir=/usr/local/var/mysql</string>
  • </array>
  • <key>RunAtLoad</key>
  • <true/>
  • <key>WorkingDirectory</key>
  • <string>/usr/local/var</string>
  • </dict>
  • </plist>

I can't think of anything else to possibly try, and I'm at a total loss why the same exact command fails when launchd runs it but succeeds when I run it!?

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.