user1190650 user1190650 - 5 months ago 13
MySQL Question

mysql command line access denied error 1045

I am trying to access mysql from the command line with:

mysql -u root --password password


but I get


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


Why is it saying that I'm not using a password?

Answer

I use the following syntax:

mysql -h [host] -u [user] -p[password]

Notice that there's no space between the -pand the [password]

The correct syntax for what you're typing is:

 mysql -h [host] -u [user] --password=[password] 

(Check reference manual... it's section 4.5.1 for version 5.5)

If you're working on the same computer where MySQL is installed, you can skip the -h [host] piece, or type -h localhost.