2

I am teaching myself how to code by watching Kevin Skoglund movies on Lynda. I am having troubles on one of the chapters in the series - creating a database. I am trying to log on to MySQL but is showing like this-

Rosss-MacBook-Air:~ rossnyland$ mysql -user -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'ser'@'localhost' (using password: YES)
Rosss-MacBook-Air:~ rossnyland$ 

The password is right because when I type a wrong password it will say (using password: NO)

What am I doing wrong? MySQL server is running, I'm using 5.7.20 version, using MAC OS x, and have tried to log on on mysqlworkbench, but message pops up saying this

Your connection attempt failed for user 'root' from your host to server at     localhost:3306:
Access denied for user 'root'@'localhost' (using password: YES)

Please:
1 Check that mysql is running on server localhost
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the root has rights to connect to localhost from your address (mysql rights define what clients can connect to the server and from which machines) 
4 Make sure you are both providing a password if needed and using the correct password for localhost connecting from the host address you're connecting from

Even I tried to delete it but no success! Please tell me what am I doing wrong or how to start over again...

  • 1
    Syntax is `mysql -u [USERNAME] -p` with [USERNAME] being ... the mysql username – brombeer Jan 25 '18 at 10:19
  • Run this query `SELECT * FROM mysql.user;` to make sure that you are entering correct password first.. – KMS Jan 25 '18 at 10:19

2 Answers2

2

The password could be right, but I doubt your user is ser.

When you use the command-line option -u, any text you put after it, is the username.

So if your username for mysql is mysql_user, you need:

$ mysql -umysql_user -p

or:

$ mysql -u mysql_user -p

or:

$ mysql --user=mysql_user --password
jeroen
  • 91,079
  • 21
  • 114
  • 132
  • no luck on each 3 suggestions you have shown me.. I have tried a different password, passwords wrong to my previous set up and still show up the same error? ERROR 1045 (28000): Access denied for user 'mysql_user'@'localhost' (using password: YES) anyway i can delete this whole process and start over? –  Jan 25 '18 at 10:27
  • @Ross What is your mysql username exactly? Using my example username is very unlikely to work. If you just installed mysql and have not used it, it is probably `root`. – jeroen Jan 25 '18 at 10:31
  • 1
    success! it has worked, thank you and everyone who has commented. much appreciated –  Jan 25 '18 at 10:39
  • @Ross Good to hear! – jeroen Jan 25 '18 at 10:40
0
  1. For the Command Line Tool error, you probably provided the wrong command. It should be:

    $ mysql -u username -p

  2. For the MySQL Workbench error, there are two possibilities:

    • You provided the wrong password for 'root'@'localhost'. Or the user 'root'@'localhost' didn't exist.
    • Your MySQL server didn't listen on the localhost interface. In other words, check the value of bind_ip in your my.cnf config file. You should provide the actual ip address by --host option in this case.

You can also check this answer I posted before, it shows you the full steps to solve this kind of problems.

walter
  • 1,199
  • 7
  • 13