I downloaded MAMP , I drive in the terminal:

 ./mysqladmin -u root - password "newpassword" 

and gives this error: error:

 'Access denied for user 'root'@'localhost' (using password: NO)' 

What to do?

  • did not work with mysqladmin , on a vskidku - but is a space really needed before the password ? and is there exactly -password ? can -p ? - BOPOH
  • one
    -p is written together and the password together with it; -p password or just-p without additional parameters and it will ask for a password separately (this is safer in principle, there will be no password in the command logs) - Mike
  • I did the book and it was written there as I wrote, now I’ll try it your way - Nikita Shchypylov
  • and the username in the database for the connection is written correctly? - misha11

1 answer 1

MySQL utilities allow you to set an account password using the --password parameter or its short form -p . In full form, if you do not specify a password, it is requested from you separately

 ./mysqladmin -u root --password 

You can specify a password on the command line, through =

 ./mysqladmin -u root --password=newpassword 

In the short form of the -p parameter, without specifying a password, the password will be requested immediately after the execution of the command

 ./mysqladmin -u root -p 

Or you can specify it immediately after the parameter by entering it without a space or additional characters.

 ./mysqladmin -u root -pnewpassword 

However, specifying a password on the command line is considered bad form, since the command remains in the logs, which in case of hacking can be used by an attacker to increase privileges. If the use of a password in a command is necessary, you can prefix the command with a space

 $ ./mysqladmin -u root -pnewpassword 

In this case, it does not fall into the story. However, in practice, they often resort to the local configuration file of the user ~ / .my.cnf, in which they indicate their preferred login and password, setting access rights to it in such a way that only the owner can read it.

 [client] user=root password=newpassword