How to change the mysql root password

后端 未结 10 1416
误落风尘
误落风尘 2020-11-30 08:56

I have installed MySQL server 5 on redhat linux. I can\'t login as root so I can\'t change the root password.

mysql -u root -p  
Enter password:  

        
10条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 09:08

    Try do this:

    mysql -u root
    

    and then:

    mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
        ->                   WHERE User='root'; 
    
    mysql> FLUSH PRIVILEGES;
    

    Worked fine for me!

提交回复
热议问题