How do I find out my root MySQL password?

前端 未结 11 1971
不知归路
不知归路 2020-12-22 17:39

I just installed MySQL on Ubuntu and the root user can\'t log in :)

How can I recover or find out my password? Using blank for password does not work.

11条回答
  •  暖寄归人
    2020-12-22 17:59

    For RHEL-mysql 5.5:

    /etc/init.d/mysql stop
    
    /etc/init.d/mysql start --skip-grant-tables
    
     mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
     mysql> FLUSH PRIVILEGES;
     mysql> exit;
    
    mysql -uroot -pnewpwd
    
    mysql>  
    

提交回复
热议问题