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

后端 未结 8 1264
夕颜
夕颜 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 21:59

    when trying to run this command i got the same error

    sudo mysqladmin create asteriskcdrdba
    

    i simply add a few lines to the code

    -u root -p
    

    and pressed the enter key. i then typed my password and hit enter. Linux liked my command as nothing more was displayed

    so maybe try

    sudo <your command here> -u <username> -p
    

    after that hit enter and enter your password

    0 讨论(0)
  • 2020-11-29 22:04
    • open my.cnf using following path

    C:\xampp\mysql\bin

    • under # The following options will be passed to all MySQL clients #password remove # comment sign if it is there password = "newpassword"

    • save file

    • close file

    • re-start mysql

    0 讨论(0)
  • 2020-11-29 22:07
    # /etc/init.d/mysqld stop
    
    Stopping MySQL: [ OK ]
    
    # mysqld_safe --skip-grant-tables &
    
    [1] 13694
    
    # Starting mysqld daemon with databases from /var/lib/mysql
    
    
    
    # mysql -u root
    
    Welcome to the MySQL monitor. Commands end with ; or \g.
    
    Your MySQL connection id is 1
    
    Server version: 5.0.77 Source distribution
    
    
    
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    
    
    
    mysql>
    
    0 讨论(0)
  • 2020-11-29 22:12

    Firstly, go to the folder support-files on terminal, and start the server by mysql.server start, Secondly, go to the folder bin on terminal or type /usr/local/mysql/bin/mysqladmin -u root -p password

    It would ask you for the old temporary password which was given to you while installing Mysql, type that and type in your new password and it would work.

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

    Set/Change password:

    mysqladmin -u root -p password
    

    Login to MySQL console:

    mysql -u root -p
    

    To exit the console:

    .\q
    
    0 讨论(0)
  • 2020-11-29 22:15

    Those are all good answers, but don't quite touch the deep cause of the problem one most likely has if faced with the OP question. That is, not knowing the ORIGINAL "starting" password created during the installation time.

    And all these command lines with "-u root ..." etc. imply knowing and using THAT password.

    Now this part from the original installation message may help anyone facing the problem above:

    Initial password for first time use of MySQL is saved in $HOME/.mysql_secret
    ie. when you want to use "mysql -u root -p" first you should see password
    in /root/.mysql_secret

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