Mysql – Homebrew Mariadb Mysql installation root access denied


So I basically am installing mariadb with mysql on my mac using homebrew.
These are the steps I made:

  • brew doctor -> worked
  • brew update -> worked
  • brew install mariadb -> worked
  • mysql_install_db -> Failed

    WARNING: The host 'Toms-MacBook-Pro.local' could not be looked up
    with /usr/local/Cellar/mariadb/10.4.6_1/bin/resolveip. This probably
    means that your libc libraries are not 100 % compatible with this
    binary MariaDB version. The MariaDB daemon, mysqld, should work
    normally with the exception that host name resolving will not work.
    This means that you should use IP addresses instead of hostnames when
    specifying MariaDB privileges ! mysql.user table already exists!

Running mysql_upgrade afterwards gave me following error:

Version check failed. Got the following error when calling the 'mysql'
command line client ERROR 1698 (28000): Access denied for user
'root'@'localhost' FATAL ERROR: Upgrade failed

I can't enter mysql like this:

mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

but like this:

sudo mysql -u root

The user table returns this:

MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
| User          | Host                    | plugin                |
| root          | localhost               | mysql_native_password |
| toms          | localhost               | mysql_native_password |
|               | localhost               |                       |
|               | toms-macbook-pro.local |                       |
4 rows in set (0.004 sec)

Best Solution

You could try to update the root password and access it afterwards

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

Exit Mysql and try to login

mysql -uroot -p # then use root as a password