I'm on mac OS Catalina 10.15.2 with a fresh install of mysql. I'm getting the following output when running the commands mysql
or mysql -v
:
ERROR 1045 (28000): Access denied for user 'timothyfisher'@'localhost' (using password: NO)
This is because the user isn't set to root
in my case. MySQL works just fine as I can enter with mysql -u root
, so this isn't really causing any problems but it gets kind of annoying.
How can I set the mysql command to use the root user instead of my computer user?
Create file ~/.my.cnf and add following lines.
[client]
user=<your_user>
password=<your_password>
More info can see https://easyengine.io/tutorials/mysql/mycnf-preference/.