How to change the mysql root password

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

    Probably a bit late here , but here is what I did :

    create file resetpass.sh which has :

    UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
    
    # mysqld_safe --init-file=resetpass.sh
    
    # service mysqld start --skip-grant-tables
    
    # mysql -u root -p
    

    Enter pass

    mysql >  change root pass ; flush privs; 
    

    quit

    # restart mysql service 
    

    The MySQL version I was using was 5.1.73 under centos6

提交回复
热议问题