zoukankan      html  css  js  c++  java
  • centos7 启动mysql

    密码无法登录问题:

    在my.cnf  中加一句   skip-grant-tables ;

    重启mysql服务;

    mysql -uroot -p;

    USE mysql ; 

    进入后,修改密码 。UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ;

    flush privileges;

    quit;

    把my.cn中的skip-grant-tables 去掉。

    重启mysql服务;

    使用新密码再次登录;

    密码正确,但登录不进去:

     mysql库中的user表缺少一个root指向localhost的数据项,导致无法本地登录。

    首先kill掉MySQL进程。

    然后在启动mysql的参数中加入 --skip-grant-tables  即: /usr/bin/mysqld_safe –skip-grant-tables &

    a.那么用root登录呢,输入正确的密码报如下错:

      

    b.在本地用mysql命令直接回车可以进入mysql,但是里面只有test和information_schema数据库,没有mysql等数据库

    修复root账户丢失的数据项。

    最后退出重启;

    代码如下:

    [root@228827 ~]# systemctl stop mysqld.service
    [root@228827 ~]# /usr/bin/mysqld_safe –skip-grant-tables &
    [root@228827 ~]# mysql
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.1.57 Source distribution
    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    mysql> use mysql
    Database changed
    mysql> select user,host,password from user where user='root';
    +——+——————-+——————————————-+
    | user | host | password |
    +——+——————-+——————————————-+
    | root | % | *A50E066E106320CF4142 |
    | root | centos | *A50E066E106320CF4142 |
    | root | 127.0.0.1 | *A50E066E1063608320CF4142 |
    +——+——————-+——————————————-+
    3 rows in set (0.12 sec)
    
    mysql> update user set host='localhost' where user='root' and host='%';
    mysql> flush privileges;
    mysql> quit;

    [root@228827 ~]# systemctl start mysqld.service

      (如有打扰,请忽略)阿里云ECS大羊群,2U4G低至1.4折,限实名新用户,需要的点吧https://promotion.aliyun.com/ntms/act/vm/aliyun-group/team.html?group=YrliaeMVUn

  • 相关阅读:
    P6406 [COCI2014-2015] Norma 分治+数学
    CF547D Mike and Fish 欧拉回路
    P6628 [省选联考 2020 B 卷] 丁香之路 欧拉路+最小生成树
    2020 CSP-S2 游记
    CF594D REQ 树状数组+质因数分解
    CF416E President's Path floyd
    CF1385F Removing Leaves 拓扑排序
    CF449C Jzzhu and Apples 思维题
    回溯法与八皇后问题
    codewars-7kyu:Sum of the first nth term of Series
  • 原文地址:https://www.cnblogs.com/mmady/p/7055481.html
Copyright © 2011-2022 走看看