12

I have just installed MariaDB via homebrew on my Mac. At the end of the installation I got the following error:

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall mariadb`

If I run brew postinstall mariadb I get:

==> /usr/local/Cellar/mariadb/5.5.34/bin/mysql_install_db --verbose --user=andrew --basedir=/usr/loca
MariaDB is hosted on launchpad; You can find the latest source and
email lists at http://launchpad.net/maria

Please check all of the above before mailing us!  And remember, if
you do mail us, you should use the /usr/local/Cellar/mariadb/5.5.34/scripts/mysqlbug script!

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

Which isn't helpful! The tutorial I was following told me to run unset TEMPDIR, then mysql_install_db --user=mysql --basedir=$(brew --prefix mariadb); running those results in the following:

/usr/local/opt/mariadb/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2)
Fatal error in defaults handling. Program aborted
chown: ./data: Operation not permitted
Cannot change ownership of the database directories to the 'mysql'
user.  Check that you have the necessary permissions and try again.

I suspect the problem has something to do with the /usr/local/etc/my.cnf.d folder. I've seen this referred to in a couple of things I've tried, but it doesn't exist on my machine. I have tried a few different mysql_install_db commands I've found in other tutorials, but they all throw up a (different) error message.

Thanks for any help!

Raskolnik
  • 491
  • 1
  • 3
  • 11

7 Answers7

29

Just open the config file at /usr/local/etc/my.cnf with your editor and comment out the following line:

!includedir /usr/local/etc/my.cnf.d
Daniel Lv
  • 867
  • 6
  • 10
  • 1
    This was my chosen solution. Adding `/usr/local/etc/my.cnf.d ` after `brew prune` every time seemed too fragile, and I'm likely to forget when it errors in future. Commenting out that line seems the best solution. – Dave Everitt Feb 24 '18 at 09:53
  • I just commented the line and it worked, thank you. – Ricardo Lucas Jun 23 '19 at 22:19
18

Having been unsuccessful with further Googling of the problem I tried manually creating a /usr/local/etc/my.cnf.d and now the mysql_install_db command seems to have worked okay. I'm not sure if this is the appropriate solution or if my.cnf.d not existing is indicative of a deeper problem with the install but, as things seem to be working, I'll mark as resolved.

[Update] As I was a little unsure in my answer whether this was the 'correct' solution I just wanted to confirm that, after a month, everything is still working fine.

Raskolnik
  • 491
  • 1
  • 3
  • 11
  • 1
    Thanks for the info. I don't understand either but creating this folder indeed fixed the issue for me too. – laurent Feb 18 '14 at 11:20
  • 3
    This totally works but you need to be careful as `brew prune` will remove `/usr/local/etc/my.cnf.d`. The fix is to replace it manually after `brew prune`, just wanted to give a heads-up. – Michael Thompson Aug 21 '14 at 14:25
6

None of the solution here helped, I had to do this:

The post-install step did not complete successfully MySQL Mac OS Sierra

in short,

  • I made a backup of the folder /usr/local/var/mysql , then removed it
  • removed Mariadb brew remove mariadb
  • reinstalled Mariadb brew install mariadb
  • run brew services start mariadb

After that I could access with mysql -u root

4

You might have an orphaned configuration file. I was able to solve this problem by deleting an old /usr/local/etc/my.cnf. YMMV.

3

If you're having this problem in 2021

This worked for me:

sudo mysql_install_db
sudo chown -R <YOUR USER NAME HERE> /usr/local/mysql # for example sudo chown -R jperez /usr/mysql
sudo chgrp -R admin /usr/local/mysql

After that, running mysql or mariadb will show the database prompt.

2

This problem seems to have recently gone away.

A simple bew upgrade resolved the problem for me.

DanielM
  • 6,380
  • 2
  • 38
  • 57
0

You may want to go

/usr/local/mysql

and delete the old MySQL file and install again