Skip to content

Instantly share code, notes, and snippets.

@nickcernis
Created July 13, 2020 15:13
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • 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.

@harryqt
Copy link

harryqt commented Aug 3, 2022

Thanks! You saved me.

@podgorniy
Copy link

Worked. This was helpful. Thanks.

@jasperf
Copy link

jasperf commented Sep 14, 2022

Thanks for this. Setting up a new laptop and this is helping a lot.

@LisaBaumann
Copy link

Thanks !!

@akshaym-hotstar
Copy link

Thanks a lot. For all the new users trying to change the password, please use the keyword mariadb instead of mysql in the above command.

@scsskid
Copy link

scsskid commented Nov 8, 2022

thank you, either using mariadb or mysql works

@Ndeta100
Copy link

This saved my life

@Valera220598
Copy link

Worked, Thanks !

@sillva
Copy link

sillva commented Feb 22, 2023

Worked beautifully!

@saiftheboss7
Copy link

This is was very helpful. Thanks a lot!

@nandastone
Copy link

Thanks!

@stefan-1st
Copy link

Worked like a charm. Thanks

@Josephcoder
Copy link

Thanks kbs.

@anjanesh
Copy link

Thanks for this. How do I bookmark this in GitHub ?

@owocc
Copy link

owocc commented Oct 22, 2023

谢谢你!这真的很有用!!太酷了~

@mantr88
Copy link

mantr88 commented Nov 11, 2023

Thanks. This has helped me.

@CarlosVP120
Copy link

Man is a life saver!

@oSamDavis
Copy link

Hero !!

@zielu92
Copy link

zielu92 commented Feb 2, 2024

If it is still not working for someone, then the root username is the same as the Mac user.

@fahkrymalta21
Copy link

Thank you so much, it work on me

@ken717w
Copy link

ken717w commented Mar 12, 2024

Saved my day!

@michael-picard
Copy link

Thanks !

@sunchuo
Copy link

sunchuo commented Apr 14, 2024

👍

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