Skip to content

Instantly share code, notes, and snippets.

@nickcernis
Created July 13, 2020 15:13
Show Gist options
  • Save nickcernis/1c2a1c98a0660d4798d55b1999d52b4c to your computer and use it in GitHub Desktop.
Save nickcernis/1c2a1c98a0660d4798d55b1999d52b4c to your computer and use it in GitHub Desktop.
Install MariaDB with brew on macOS and fix the “access denied” issue

Attempting mysql -u root fails with Access denied for user 'root'@'localhost immediately after doing brew install mariadb and starting mariadb with brew services start mariadb.

To fix it (with MariaDB still running):

  1. sudo mysql then enter your Mac user password
  2. ALTER USER 'root'@'localhost' IDENTIFIED BY 'newrootpassword'; replacing newrootpassword with the password you wish to use for the MariaDB root user.
  3. Ctrl-C to exit mysql.

You should then be able to connect to MariaDB with mysql -u root -p, then entering the root password when prompted.

@mwangaben
Copy link

Thanks alot

@vanderw
Copy link

vanderw commented Aug 10, 2024

Thanks
At first, i don't believe a reset is needed after a new installation. But i really hard reset it over years. I wont past the relative commands i used to prevent misleading
useful knowledges increased.

@netzbub
Copy link

netzbub commented Aug 31, 2024

Thanks a lot !!
Still good - even four years later ... 😅

@xiaozongyang
Copy link

cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment