简体   繁体   中英

How to specify default user in mac OS when running the mysql command in terminal?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM