zoukankan      html  css  js  c++  java
  • Mysql找回管理员password

    我们使用MYSQL的时候有可能由于种种原因忘记ROOTpassword,假设是那样数据库可能就废掉了。可是今天给大家分享下找回ROOTpassword的方法或者说是在不知道rootpassword的情况下改动ROOTpassword,可是还是建议大家对rootpassword慎重保管,防止一些不必要的麻烦

    找回管理员password:

    [root@localhost~]# service mysqld stop

    Shutting down MySQL....[确定]

    [root@localhost~]# vim /etc/init.d/mysqld

    大约在283行:

          $bindir/mysqld_safe --datadir="$datadir"--pid-file="$mysqld_pid_file_path" $other_args >/dev/null2>&1 &

          wait_for_pid created "$!""$mysqld_pid_file_path"; return_value=$?

    更改为

          $bindir/mysqld_safe --skip-grant-tables --skip-networking

    --datadir="$datadir"--pid-file="$mysqld_pid_file_path" $other_args >/dev/null2>&1 &

          wait_for_pid created "$!""$mysqld_pid_file_path"; return_value=$?


    保存退出

    mysql> use mysql

    Readingtable information for completion of table and column names

    You canturn off this feature to get a quicker startup with -A

     

    Databasechanged

    mysql> select user,host,password from user;

    +---------+-----------------------+-------------------------------------------+

    |user    | host                  | password                                  |

    +---------+-----------------------+-------------------------------------------+

    |root    | localhost             |*4941369BD46398A2BDEEC85411065D7137D4EA0F |

    |root    | localhost.localdomain |*4941369BD46398A2BDEEC85411065D7137D4EA0F |

    |root    | 127.0.0.1             |*4941369BD46398A2BDEEC85411065D7137D4EA0F |

    |tianke  | %                     |*A399693A49F7EC7C548D0FC376FA52AD293A552F |

    |tianke1 | %                     |*EEAC51414F1AE247D67F47A875BDB134CF39986C |

    +---------+-----------------------+-------------------------------------------+

    5 rowsin set (0.01 sec)

    改动rootpassword

    mysql> update user setpassword=password('123456')  whereuser='root';

    QueryOK, 3 rows affected (0.00 sec)

    Rowsmatched: 3  Changed: 3  Warnings: 0

    然后将服务再次停掉,然后再将掺数改回重新启动mysql就可以。

  • 相关阅读:
    [ERROR]SFTP is not available
    [BTS] Loading property information list by namespace failed or property not found in the list. Verify that the schema is deployed properly.
    IBatisNet系列执行存储过程
    NickLee.FortuneBase数据库sql server修正版
    NickLee.FortuneBase数据库sql server版新增页面详细说明
    实战CRM系统项目:1.需求分析
    项目实战之CRM系统(一)前言
    ASP.NET基础权限系统
    NickLee.FortuneBase数据库sql server版新增页面视频演示
    NickLee.FortuneBase数据库sql server版工具篇
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5179931.html
Copyright © 2011-2022 走看看