MacOS: When suddenly, after a system crash, mysql server instance no longer starts. What can I do?

Recently, after a system crash and consequent system reboot, mysql stopped working. I tried to manually start the server but had no luck on this.
sudo /usr/local/mysql/support-files/mysql.server start
Tried to list active processes for mysql and that’s when I noticed a weird behaviour, there was a mysql process but each time I executed the previous command the process had a different PID.
 ps -a | egrep mysql
But what happened? I tried to figure out were was the log file located but had no luck on this too. That’s when So I came across this post that suggests settings up the error log output path directly in the launch .plist file as follows:
vim /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

....then once the file opens: 

Make sure to add the following line: 
    <key>StandardErrorPath</key> <string>/tmp/mysql.err</string>


Just like I did to my own file: 

<?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>StandardErrorPath</key> <string>/tmp/mysql.err</string>
    .....other properties
  
  
Save you changes and run chmod + chown the file as follows
  sudo chmod 644 /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
  sudo chown root:wheel /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
  
Once I did this, my log file was instantly generated
tail -f /tmp/mysql.err
And that’s when I saw “Could not open file ‘/usr/local/mysql/data/mysqld.local.err’ for error logging: Permission denied”. Clear enough ? In your case the error might differ but at least you will be able to determine the cause of the problem and act in consequence.
2022-01-28T16:32:21.034425Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) starting as process 64049
2022-01-28T16:32:21.038645Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2022-01-28T16:32:21.040522Z 0 [ERROR] [MY-010187] [Server] Could not open file '/usr/local/mysql/data/mysqld.local.err' for error logging: Permission denied
2022-01-28T16:32:21.040644Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-01-28T16:32:21.040849Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.17)  MySQL Community Server - GPL.
2022-01-28T16:32:31.355665Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) starting as process 64131
2022-01-28T16:32:31.359642Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2022-01-28T16:32:31.361306Z 0 [ERROR] [MY-010187] [Server] Could not open file '/usr/local/mysql/data/mysqld.local.err' for error logging: Permission denied
To fix the problem in my dev environment just did
chmod -R 777 /usr/local/mysql/data
And now everything works just fine 😊 👋 See ya

Leave a Reply

Close Menu