[(pyEnv) Anants-MacBook-Pro:litibackend anantchandra$ brew postinstall mysql
==> Postinstalling mysql
==> /usr/local/Cellar/mysql/8.0.11/bin/mysqld --initialize-insecure --user=anantchandra --basedir=/usr/local/Cellar/mysql/8.0.11 --datadir=/usr/local/var/mysql --tmpdir=/tmp
Last 15 lines from /Users/anantchandra/Library/Logs/Homebrew/mysql/post_install.01.mysqld:
2018-06-15 04:41:04 -0700
/usr/local/Cellar/mysql/8.0.11/bin/mysqld
--initialize-insecure
--user=anantchandra
--basedir=/usr/local/Cellar/mysql/8.0.11
--datadir=/usr/local/var/mysql
--tmpdir=/tmp
2018-06-15T11:41:04.901191Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.11/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 37841
2018-06-15T11:41:04.903504Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2018-06-15T11:41:04.903537Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-06-15T11:41:04.903701Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.11/bin/mysqld: Shutdown complete (mysqld 8.0.11) Homebrew.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall mysql`

- 18,169
- 13
- 73
- 107

- 113
- 1
- 1
- 6
-
1I have the same just after upgrading from 5.7 into 8. – Paweł Gościcki Jun 17 '18 at 17:40
-
From what I can tell brew corrupts the Mysql 5.7 data directory so that it cannot be 1) read/upgraded by mysql version 8 and 2) can no longer be used by 5.7 (`brew install mysql@5.7` errors out with InnoDB errors) – Paweł Gościcki Jun 17 '18 at 18:19
-
What is your question? Where is the context? What have you tried to fix the warning? – bfontaine Jun 18 '18 at 09:38
4 Answers
I was able to go back to 5.7 for anyone who wants to:
brew uninstall mysql
brew install mysql@5.7
brew link --force mysql@5.7
mysql.server start
mysql_secure_installation
After all that, I'm back in 5.7 with all my databases intact. In my case, I knew the data in the databases wasn't crucial, so I didn't attempt to backup the data in advance. Worked fine for me. If you have irreplaceable data in your local databases, you might want to tread carefully. I didn't lose data, but I don't want anyone else to lose data on my advice either. ;)
Normally, I don't mind a MySQL upgrade, but 8.0 looks to have compatibility issues I'd like to vet before going forward, and in the meantime, I'd rather be back on a version that doesn't force me to deal with those issues.

- 5,459
- 3
- 34
- 52
-
getting exception ... ERROR! The server quit without updating PID file (/usr/local/var/mysql/SW-LP09449.local.pid). – whishky Dec 02 '19 at 15:54
-
-
yes, and https://stackoverflow.com/questions/59151944/mysql-5-7-installed-via-brew-now-getting-error-the-server-quit-without-updating – whishky Dec 03 '19 at 17:33
The installation or re-installation, brew install mysql
, created the default data directory, and the post installation does not handle it...
Simply move the existing data directory (this moves it to a sibling directory, named with the process id of the shell):
$ mv /usr/local/var/mysql /usr/local/var/mysql-$$
or might need super user privileges...
$ sudo mv /usr/local/var/mysql /usr/local/var/mysql-$$
Then run:
$ brew postinstall mysql

- 369
- 2
- 5
-
1I receive the same message after a failed installation, then uninstallation and reinstallation...the above fixed worked for me. – Scott Robert Schreckengaust Jun 20 '18 at 23:47
-
This solution is incomplete. The question is how can I upgrade my databases to MySQL 8. Not how can I remove MySQL 5.7 databases completely. – Paweł Gościcki Jun 22 '18 at 09:29
-
@ScottRobertSchreckengaust could you explain why adding the process id `-$$` helps the postinstallation to handle it? Ty – ilam engl May 18 '22 at 12:41
-
The `$$` will substitute the PID (process identifier) of the executing shell making it a unique destination in case there has been a previous move. An alternative would be a datetime stamp yet that is not created the same for various shells – Scott Robert Schreckengaust May 20 '22 at 13:14
First, backup the content of your data directory: /usr/local/var/mysql
by copying it to a safe place.
The error happens because the post-install script check if a file /usr/local/var/mysql/mysql/user.frm
exists. For whatever reason you don't have this file. The postinstall script then tries to install a new MySQL 8 database by running mysqld
with --initialize-insecure
but as the directory already contains some data from MySQL 5.7 the script halts.
Here is the correspoding part of the script in mysql.rb
:
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
There is several possible solutions. If you can still run your MySQL 5.7 database, export everything with mysqldump then install a fresh MySQL 8 database by removing all content in /usr/local/var/mysql
and then import everything back again. Another solution, is to use the mysql_upgrade tool.
P.S.: Personally, I use the formula mysql@5.7 and I will in the future switch to MariaDB.

- 56,620
- 24
- 188
- 240
-
1I guess it's mostly an issue with `brew`, that it cannot upgrade your databases locally during mysql upgrade and then you cannot easily fix it yourself. Thanks for the detailed explanation. – Paweł Gościcki Jun 24 '18 at 07:54
-
agree with @PawełGościcki, there are some issues with brew when installing MySQL 8. If you want to get MySQL 8 running, you have to download it from https://dev.mysql.com/downloads/mysql/. However, removing `/usr/local/var/mysql` directory can help install 5.7 – Fred Lai Sep 02 '18 at 11:02
-
@PawełGościcki I got the same issue after `brew uninstall mysql` followed by `brew cleanup`. I then reinstalled from scratch. So I'm confused. Why this is still happening especially because find \*mysql\* retuned none... – ilam engl May 18 '22 at 12:34
According to this link, below command saves me on macOS Mojave:
sudo chown -R $(whoami) /usr/local/*

- 327
- 2
- 12
-
That's what helper after struggling for some time, thanks for bothering with writing this answer! – bolt May 18 '21 at 14:30