0

I got a problem when I try to secure my MariaDB installation with Homebrew (macOS Big Sur 11.4 and MacBook Pro M1 chip environment).

I installed MariaDB through Homebrew with that command and got no errors:

brew install mariadb

Then when trying to do the recommended secure process:

sudo /opt/homebrew/bin/mysql_secure_installation

I got the error :

touch: .my.cnf.25188: Read-only file system
touch: .mysql.25188: Read-only file system
chmod: .my.cnf.25188: No such file or directory
chmod: .mysql.25188: No such file or directory

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
/opt/homebrew/bin/mysql_secure_installation: line 249: .my.cnf.25188: Read-only file system
/opt/homebrew/bin/mysql_secure_installation: line 250: .my.cnf.25188: Read-only file system
/opt/homebrew/bin/mysql_secure_installation: line 251: .my.cnf.25188: Read-only file system
/opt/homebrew/bin/mysql_secure_installation: line 253: .my.cnf.25188: Read-only file system
/opt/homebrew/bin/mysql_secure_installation: line 218: .mysql.25188: Read-only file system
/opt/homebrew/bin/mysql_secure_installation: line 220: .mysql.25188: No such file or directory

I searched a lot through the web but cannot find any solution.

Somebody had encounter and find a solution for that ?

Miguel Bocquier
  • 2,449
  • 5
  • 22
  • 38

1 Answers1

2

Why did you guys keeping trying sudo with brew. Homebrew doesn't support root privilege. Don't prepend sudo before brew.

  1. Fix ownership of homebrew related files
# For x86 Mac
sudo chown -R $(whoami):admin /usr/local/*

# For M1 Mac
sudo chown -R $(whoami):admin /opt/homebrew/*
  1. Run /opt/homebrew/opt/mariadb/bin/mysql_secure_installation

Sorry, I don't wanna explain again why brew doesn't support sudo here. Check this answer for anyone who is interested.

Simba
  • 23,537
  • 7
  • 64
  • 76
  • Thanks for help. Sorry but when I do `sudo chown -R $USER:admin /opt/homebrew/*` I got the error : `chown: /Users/myname/mynamedmin: illegal user name` – Miguel Bocquier Aug 07 '21 at 15:49
  • 1
    @migswd Try replace `$USER` with `$(whoami)`. Or type your username manually. The `yourusername` in `/Users/yourusername`. – Simba Aug 07 '21 at 16:05
  • Not working for me using M2 mac, still same error. Btw, it seems even weird as I never used any sudo with brew – Allan Raquin Apr 11 '23 at 19:00