Search code examples
mysqlcorrupt

"Cannot load from mysql.procs_priv. The table is probably corrupted" on Osx / homebrew


Problem:

Getting Cannot load from mysql.procs_priv. The table is probably corrupted when trying to create new mysql user.

Platform: OSX Yosemite, Homebrew

Tried all the below and DID NOT WORK:

  1. Upgrading: mysql_upgrade -uroot -p
    • I had to use --force because of this: This installation of MySQL is already upgraded to 5.7.9, use --force if you still need to run mysql_upgrade
    • Next I had to use --skip-version-check because of this: Error: Server version (5.7.18) does not match with the version of the server (5.7.9) with which this program was built/distributed. You can use --skip-version-check to skip this check.
    • still didn't work after all that
  2. Reducing the query to most obvious and taking out functions: CREATE USER 'newuser';, still throws same error.
  3. Repairing the mysql.procs_priv table
  4. Changing all the char columns in mysql.procs_priv to varchar, as suggested here. Well he suggested changing to text but that seemed too crazy for a core mysql table.

Solution

  • Completely removing mysql and reinstalling it worked (less than 15 mins).

    1. UNINSTALL AND PURGE MYSQL FROM SYSTEM

    1. Back up databases.
    2. Stop and kill any MySQL processes. Check for processes with ps -ax | grep mysql
    3. Uninstall mysql

      brew remove mysql
      brew cleanup
      
    4. Remove all the residual files

      sudo rm /usr/local/mysql
      sudo rm -rf /usr/local/var/mysql
      sudo rm -rf /usr/local/mysql*
      sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
      sudo rm -rf /Library/StartupItems/MySQLCOM
      sudo rm -rf /Library/PreferencePanes/My*
      
    5. Unload previous auto login

      launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist 
      
    6. Remove previous config. Delete the line MYSQLCOM=-YES- from /etc/hostconfig

    7. Remove previous preferences

      sudo rm -rf ~/Library/PreferencePanes/My*
      sudo rm -rf /Library/Receipts/mysql*
      sudo rm -rf /Library/Receipts/MySQL*
      sudo rm -rf /private/var/db/receipts/*mysql*
      sudo rm -rf /private/var/db/receipts/*mysql*
      sudo rm -rf /private/var/mysql
      
    8. Optional, restart computer. I didn't.

    2. INSTALL MYSQL

    1. Install Mysql

      brew install mysql
      
    2. Set to run on startup

      brew services start mysql
      
    3. Secure the installation

      mysql_secure_installation