$ mysql.server stop
or
$ brew services stop mariadb
or
$ mysqladmin shutdown
then start mariab db with
$ mysqld --skip-grant-tables &
open new terminal tab and run
$ mysql
then flush privileges
MariaDB [(none)]> flush privileges;
now set your new password as eg: 1234
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';