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

后端 未结 8 1265
夕颜
夕颜 2020-11-29 21:28

I\'m trying to set the password of the user root but I\'m gettin the error below, any idea?

+----------------------------------------------------------------         


        
相关标签:
8条回答
  • 2020-11-29 22:21
    $ mysqladmin -u root -p password
    Enter password: 
    New password: 
    Confirm new password:
    

    password is to be typed literally. It's a command. You don't have to substitute password with your actual password.

    0 讨论(0)
  • 2020-11-29 22:22

    This is basically a more detailed version of a previous answer.

    In your Terminal, go to the location of your utility program, mysqladmin

    For example, if you were doing local development and using an application like M/W/XAMP, you might go to the directory:

    /Applications/MAMP/Library/bin

    This is where mysqladmin resides.

    If you're not using an application like MAMP, you may also be able to find your local installation of mysql at: /usr/local/mysql

    And then if you go to: /usr/local/mysql/bin/

    You are in the directory where mysqladmin resides.

    Then, to change the password, you will do the following:

    1. At your Terminal prompt enter the exact command below (aka copy and paste) and press enter. The word "password" is part of the command, so don't be confused and come to the conclusion that you need to replace this word with some password you created previously or want to use in the future. You will have a chance to enter a new password soon enough, but it's not in this first command that you will do that:

      ./mysqladmin -u root -p password

    2. The Terminal will ask you to enter your original or initial password, not a new one yet. From the above image you provided, it looks like you have one already created, so enter it here:

    Enter password: oldpassword

    1. The Terminal will ask you to enter a new password. Type it here and press enter:

    New password: newpassword

    1. Then the Terminal will ask you to confirm the new password. Type it here and press enter:

    Confirm new password: newpassword

    Reset or restart your Terminal.

    In some cases, as with M/W/XAMP, you will have to update this new password in various files in order to get your application running properly again.

    0 讨论(0)
提交回复
热议问题