简体   繁体   中英

mysql -v ERROR 1045 (28000): Access denied for user root'@'localhost' (using password: NO)

I need help. When Checking mySQL version I get this error. I do not use mysql a lot and I am trying to set up a Magento store through command line. However, first I am trying to set up mySql from the database. I am using Mac OS Catalina and Zsh terminal.

Error.

mysql -v
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I know it must be something with my database but I am confused. Any help would be appreciated. When I try to download Magento 2 setup install I get this similar error.

 --db-user=root --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com --admin-user=admin --admin-password=123123q --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

In InstallCommand.php line 264:

  Parameter validation failed

EDIT: However, When I connect to mysql -u root I can connect to the database no problem.

You need to pass in the user and password when running mysql from the command line

mysql -u root -p [enter password]

Alternatively, you can set up a mylogin.cnf (or a.my.cnf) to save the user/password as a file, so you don't need to remember it.

https://dba.stackexchange.com/questions/86595/how-can-i-make-mysql-client-read-password-from-mylogin-cnf

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