• Linux重置MySQL密码


    1.停止mysql程序

    [root@H0f ~]# service mysqld stop
    Stopping mysqld:                                           [  OK  ]
    

     2.打开mysql配置文件

    [root@H0f ~]# vim /etc/my.cnf
    搜索mysqlld /mysqld
    [mysqld]#下一行添加
    skip-grant-tables  #忽略MySQL权限问题,直接登录

     3.开启MySQL服务

    [root@H0f ~]# service mysqld start
    

     4.无密码直接进入mysql

    [root@H0f ~]# mysql
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.1.73-log Source distribution
    
    Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    

    5.使用mysql表,进行修改密码

    mysql> use mysql
    Database changed
    mysql> update user set password=password("123") where user="root";#密码修改为123
    Query OK, 3 rows affected (0.00 sec)
    Rows matched: 3  Changed: 3  Warnings: 0
    

     6.刷新权限

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    

     7.杀死所有mysqld进程

    [root@H0f ~]# killall mysqld
    [root@H0f ~]# ps -ef|grep mysqld
    root      53342  45198  0 20:57 pts/6    00:00:00 grep mysqld
    

     8.开启mysqld服务

    [root@H0f ~]# service mysqld start
    Starting mysqld:                                           [  OK  ]
    

     9.测试进入mysql

    [root@H0f ~]# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.1.73-log Source distribution
    
    Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql>
    
  • 相关阅读:
    Ajax省市区无刷新单表联动查询
    Hadoop2.0、YARN技术大数据视频教程
    零基础DNET B/S开发软件工程师培训视频教程
    零基础DNET CS开发视频教程
    HTML5开发框架PhoneGap实战视频教程
    Web前端开发视频教程
    FluentData 轻量级.NET ORM持久化技术详解
    前端 MVVM 框架KnockOut.JS深入浅出视频教程
    ASP.NET Web开发项目实战视频教程
    零基础到CS开发高手通用权限管理系统全程实录
  • 原文地址:https://www.cnblogs.com/someone9/p/8716592.html
Copyright © 2020-2023  润新知