恢复忘掉的mysql root密码

1. 干掉mysqld进程
    

 killall mysqld


2. 用下面命令启动
 

    mysqld_safe –skip-grant-tables


3. 复制一个终端,已空密码的方式进入mysql

     mysql -u root
     mysql> show databases;
     mysql> use mysql;
     show tables;
     mysql> select * from user;


4. 更新root密码

     mysql> update MySQL.user set password=PASSWORD(‘newpassword’) where User=‘root’; 
     mysql> flush privileges;


5. 返回上一个终端,结束mysqld_safe的进程
6. 重新启动服务,用新密码尝试登陆    


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章