How to change the mysql root password

后端 未结 10 1433
误落风尘
误落风尘 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:24

    One option is to save UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root'; into a file and then manually start mysqld with --init-file=FILENAME. Once the server starts, it should reset your password, and then you should be able to log in. After this, you should shut down the server and start it normally.

提交回复
热议问题