This tip can be used if you forget or want to change MariaDB root password.
Make sure to install MariaDB using Homebrew.
This tip is from Update root password in MariaDB 10.4 on MacOS
- Stop currently running MariaDB server.
- Start new instance with
mysqld_safe --skip-grant-tables
option. - Access to MariaDB from CLI, often being mysql.
- Execute SQL query to change password.
UPDATE user SET password=PASSWORD('secret') WHERE User='root';
-- Or
UPDATE user SET authentication_string=PASSWORD('secret') WHERE User='root';
Final step is to execute FLUSH PRIVILEGES;
.
- Start MariaDB as usual via Homebrew
brew services start mariadb
- Launch mysql client with
sudo
:$ sudo mysql -u root
. Make sure to havesudo
; otherwise, it won't work. - Execute SQL query to change or reset
root
password.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'secret';
-- Or
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('secret');
Final step is to execute FLUSH PRIVILEGES;
.
Visit Pete Houston's blog for more coding tips and tricks.