Linux 下 mysql 重置密码

  1. 查看服务状态:  

    • ps -ef | grep mysqld 

    • service mysqld status 

  2. 关闭服务

    service mysqld stop
    
  3. 增加配置:无权限认证

    1. vi /etc/my.cnf

    2.  增加行 skip-grant-tables

    3. :wq  

    4. cat /etc/my.cnf

  4. 启动服务
       service mysqld start

  5. 登录服务
        mysql

  6. 查看

    mysql>  select host,user,authentication_string from mysql.user;
    

  7. 更新root用户密码为root

     mysql> update mysql.user set  authentication_string = password('root') where user ='root';
     mysql> quit;
    

  8. 加载权限表

    mysql> flush privileges;
    

  9. **删除无权限认证配置**,并重启
      service mysqld restart

  10. 验证 *   mysql -uroot -proot *   mysql -u root -p mysql -P 3306

评论

暂无评论