zoukankan      html  css  js  c++  java
  • MySQL 超级管理员密码忘记了,怎么处理

    --skip-grant-tables    :跳过授权表
    --skip-networking      :跳过TCP/IP连接
    [root@master1 ~]# pkill mysqld
    [root@master1 ~]# /etc/init.d/mysqld start
    Starting MySQL. SUCCESS! 
    [root@master1 ~]# /etc/init.d/mysqld stop
    Shutting down MySQL.. SUCCESS! 
    [root@master1 ~]# systemctl start mysqld --skip-grant-tables
    systemctl: unrecognized option '--skip-grant-tables'
    [root@master1 ~]# service mysqld start --skip-grant-tables
    Starting MySQL. SUCCESS! 
    [root@master1 ~]# mysql

    (1)关闭数据库

    [root@master1 ~]# systemctl stop mysqld

    (2)使用安全模式启动

    [root@master1 ~]# mysqld_safe --skip-grant-tables --skip-networking &
    或者
    [root@master1 ~]# service mysqld start --skip-grant-tables --skip-networking

    (3)登录数据库并修改密码

    [root@master1 ~]# mysql
    
    mysql> alter user root@'localhost' identified by 'mysql';
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
    mysql>
    mysql> flush privileges;    # 手工加载授权表
    mysql> alter user root@'localhost' identified by 'mysql';

    (4)重启数据库到正常模式

    [root@master1 ~]# service mysqld restart
    Shutting down MySQL.. SUCCESS! 
    Starting MySQL. SUCCESS!
  • 相关阅读:
    jedis 连接 虚拟机内redis服务
    数据库存储过程项目总结
    前端jsp联系项目相关经验
    学习做项目的一些随笔
    循环
    字典
    集合
    元组
    列表
    字符串
  • 原文地址:https://www.cnblogs.com/dinghailong128/p/13404935.html
Copyright © 2011-2022 走看看