1

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?

Timothy Fisher
  • 1,001
  • 10
  • 27

1 Answers1

1

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/.

Puckwang
  • 424
  • 1
  • 5
  • 11
  • Doing this logs me straight into mysql without showing the output of the command though. Normally if you run `mysql -v` it shows just the version, or if you run `mysql` alone it will show a list of commands. With this if I type in either of those it just throws me directly into mysql to start running queries. – Timothy Fisher Jan 21 '20 at 08:18
  • `mysql -v` is verbose mode. you want to say is `mysql -V` ? – Puckwang Jan 21 '20 at 09:11