Homebrew-core: mysql formula does not uninstall cleanly, or [email protected] doesn't work

Created on 18 Jun 2018  路  14Comments  路  Source: Homebrew/homebrew-core

On a completely clean macOS High Sierra install, I brew installed the mysql formula, not realizing it was recently updated to 8.x. I brew uninstalled the mysql formula, and brew installed the [email protected] formula. The mysql client cannot connect:
$ mysql -u root ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Turns out, the server can't start:
$ mysql.server start Starting MySQL ./usr/local/Cellar/[email protected]/5.7.22/bin/mysqld_safe: line 647: /usr/local/var/mysql/<hostname>.err: No such file or directory Logging to '/usr/local/var/mysql/<hostname>.err'. /usr/local/Cellar/[email protected]/5.7.22/bin/mysqld_safe: line 144: /usr/local/var/mysql/<hostname>.err: No such file or directory /usr/local/Cellar/[email protected]/5.7.22/bin/mysqld_safe: line 198: /usr/local/var/mysql/<hostname>.err: No such file or directory /usr/local/Cellar/[email protected]/5.7.22/bin/mysqld_safe: line 906: /usr/local/var/mysql/<hostname>.err: No such file or directory /usr/local/Cellar/[email protected]/5.7.22/bin/mysqld_safe: line 144: /usr/local/var/mysql/<hostname>.err: No such file or directory ERROR! The server quit without updating PID file (/usr/local/var/mysql/<hostname>.pid).

Investigation suggests exactly these symptoms when trying to run 5.7 after an incompletely uninstalled 8.x installation. It could also be that the [email protected] formula is broken. I've tried all the stuff with chown and chmod on various /tmp/ directories and files.

outdated

Most helpful comment

I'm guessing it's probably tripped up by the fact that the database was created for MySQL 8, and then downgraded to an older version. You can try deleting the database and recreating it. Note that this will drop all of your databases and remove all data, so take backups if you have any local data you want to keep.

rm -rf /usr/local/var/mysql && brew postinstall [email protected] && brew services restart [email protected]

All 14 comments

Running sudo mysql.server start does log to an error file. Relevant error:
2018-06-18T17:08:39.825080Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

Taking that advice:
$ sudo mysql_upgrade mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) while connecting to the MySQL server Upgrade process encountered error and will not continue.

I'm guessing it's probably tripped up by the fact that the database was created for MySQL 8, and then downgraded to an older version. You can try deleting the database and recreating it. Note that this will drop all of your databases and remove all data, so take backups if you have any local data you want to keep.

rm -rf /usr/local/var/mysql && brew postinstall [email protected] && brew services restart [email protected]

$ rm -rf /usr/local/var/mysql && brew postinstall [email protected] && brew services restart [email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using brew postinstall [email protected]
$ brew postinstall [email protected] && brew services restart [email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using brew postinstall [email protected]
$ brew postinstall [email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using brew postinstall [email protected]

If I ask homebrew to remove a formula, it should _remove_ the formula, not leave the system in a broken state that interferes with a future formula. If I brew doctor at that point, it should _fix_ the new formula, not think the system is in a working state. Either or both of the mysql or [email protected] formulae are incorrect.

Removing mysql doesn't remove the data on Linux either, there's actually no precedent I know of for removing user data when removing a program.

The trouble is that the system is now in an apparently unrecoverable state, due specifically to the incomplete removal of one formula (I never added any data before uninstalling). How am I to proceed?

@matthewspeck The error you mentioned in https://github.com/Homebrew/homebrew-core/issues/29173#issuecomment-398127286 is actually created by a conflict between the MySQL 8 and MySQL 5 installations.

MySQL v5 is unable to start due to incompatible log files you can workaround that by backup up the ib_logfile files within the /usr/local/var/mysql folder. Then restarting MySQL 5 will regenerate the file.

MySQL error log:

2018-06-18T11:22:59.119244Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-06-18T11:22:59.133263Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-06-18T11:22:59.133567Z 0 [ERROR] InnoDB: Unsupported redo log format. The redo log was created with MySQL 8.0.11. Please follow the instructions at http://dev.mysql.com/doc/refman/5.7/en/upgrading-downgrading.html
2018-06-18T11:22:59.133590Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-06-18T11:22:59.578008Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-06-18T11:22:59.578053Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-06-18T11:22:59.578066Z 0 [ERROR] Failed to initialize builtin plugins.
2018-06-18T11:22:59.578085Z 0 [ERROR] Aborting

This new [email protected] formula really should not install over top of the existing older mysql formulas without at least producing a warning. I just spent my morning manually fixing this after it was installed over top the old formula.

You told it to upgrade though and it did, quite successfully. Otherwise every update would need a warning that it could break things, thus rendering the warning useless.

I uninstalled mysql 8 and brew install [email protected] again (after cleanup and doctor). Now I get:
zsh: command not found: mysql
(Same thing for mysql_secure_installation)

I do not understand, why mysql is not a command anymore...
What do i have to do to make mysql5.7 run?

Probably have to link it first (more info available in the caveats)

Damn it! I just read the line in question... One of those incidents, where I had to post the problem just to find the solution just 2 seconds afterwards... Sorry!
And thank you, @SMillerDev for replying so quickly!

I did brew install [email protected] then brew switch mysql 5.7.22

Ty @mistydemeo, your command worked for me.

Had some really weird behaviours prior to that:

~/projects/hostmaker-api (production)
 馃檲 馃憠  which mysql
/usr/local/opt/[email protected]/bin/mysql
~/projects/hostmaker-api (production)
 馃檲 馃憠  mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 8.0.12 Homebrew
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuna9 picture yuna9  路  4Comments

BluePawDev picture BluePawDev  路  3Comments

gregvirgin picture gregvirgin  路  3Comments

oli-laban picture oli-laban  路  3Comments

ghostbar picture ghostbar  路  4Comments