MySQL Forums
Forum List  »  Newbie

Unable to connect MYSQL from command line but works in MySQL Workbench
Posted by: Colin Parry
Date: June 08, 2018 03:36AM

Had a very strange issue where after install I was able to log into my MySQL database as root via MySQL workbench, but not from the command line. When using the command line I received the error

C:\Users\cparry>mysql -u -root -p
Enter password: ************
ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password: YES)

After much investigation I found that the issue was being caused by using the -p option with no password. To fix the issue I simply supplied the actual password and login worked.

mysql --user=root --password=Pa55word

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.5.60 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Options: ReplyQuote


Subject
Written By
Posted
Unable to connect MYSQL from command line but works in MySQL Workbench
June 08, 2018 03:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.