密码无法登录问题:

在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账户丢失的数据项。

最后退出重启;

代码如下:

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

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

centos7 启动mysql的更多相关文章

  1. CentOS7安装mysql后无法启动服务,提示Unit not found

    首发日期: 2018-01-30 现象: 在centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not found [明明已经安装了, ...

  2. centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not foundc

    现象: 在centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not found [明明已经安装了,为什么提示不存在呢?] 原因: 在 ...

  3. MySQL下载地址与Centos7安装MySQL以及启动问题排查

    目录 一.MySQL国内镜像下载 二.国内镜像相关站点 三.Centos7安装MySQL5.7 1. 下载并解压至/usr/local 2. 配置信息 3. 用户及用户组管理(提高安全) 4. 初始化 ...

  4. 解决CentOS7 无法启动mysql 的解决办法

    MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方 ...

  5. 如何搭建lamp(CentOS7+Apache+MySQL+PHP)环境 [转]

    在网上搜资料,自己在本地虚拟机上尝试搭建,弄了整整一天一夜,终于弄好了.网上的资料,虽然很多,但大多都是重复的,拿去试了之后,又很多都不能得到正确的结果.最终找到了适合我的linux环境的搭建方式;在 ...

  6. centos7安装mysql

    centos7安装mysql 1 查找系统是否安装了myql rpm -q mysql mysql-server1.1如果安装了.就删除 sudo yum -y remove mysql mysql- ...

  7. centos7安装mysql(yum)

    centos7安装mysql(yum) ----安装环境----依赖安装----检查mysql是否已安装----安装----验证是否添加成功----选择要启用的mysql版本----通过Yum安装my ...

  8. 如何搭建lamp(CentOS7+Apache+MySQL+PHP)环境

    我的环境:虚拟机是:VMware-workstation-full-8.0.0-471780.exe:Linux系统用的是:CentOS-7-x86_64-Minimal-1503-01.ios;(阿 ...

  9. CentOS7下Mysql 5.6.30安装与配置

    环境:centos 7 x64 先下载mysql安装包 打开 http://dev.mysql.com/downloads/mysql/  选择 linux - Generic 再选择 下载完毕后,得 ...

随机推荐

  1. 移动端常用的 meta设置

    <meta charset="utf-8"> <meta name="viewport" content="width=device ...

  2. suffix word al ain aire out ~A1

    1◆ al 2◆ ain ~的人   3◆ aire 表名词  

  3. window.open打开新窗口 参数

    1,基本描述 oNewWindow = window.open( sURL , sName , sFeatures, bReplace) window.open在打开一个窗口(其url为sURL)后, ...

  4. unity中导入插件时报错处理办法

    错误如下: Unhandled Exception: System.TypeLoadException: Could not load type 'System.ComponentModel.Init ...

  5. 安装Adobe Acrobat XI Pro

    从网上下载Adobe Acrobat XI Pro这款软件,下载后将其解压到我们的电脑上,然后找到setup.exe双击安装它,安装时选择“使用试用版本或订阅” 2 选择“自定义”   自定义安装组件 ...

  6. 【资料搜集】DirectX学习

    [网站推荐:]GameRes游资网-游戏开发者门户 http://www.gameres.com/ [基础知识:] <游戏编程>第一部 基础篇 - GameRes.com http://d ...

  7. Linux搭建Hadoop集群---Jdk配置

    三台虚拟机:master slave1 slave2 192.168.77.99 master 192.168.77.88 slave1 192.168.77.77 slave2   1.修改主机名: ...

  8. Ubuntu server 网络配置中遇到的问题

    Ubuntu server 网络配置中遇到的问题 图片中ip地址有可能和文字不符,请不要在意太多,知道原理即可 - 1.首先就是要配置ip地址 vim /etc/network/interfaces ...

  9. C++基础知识:STL简介

    1.标准模板库STL ― STL , 即 : Standard Template Library , 是 C++的一部分― STL是常用数据结构和算法的集合― STL的目标是标准化组件 , 提高开发效 ...

  10. 1.6socket服务器传送文件--gui窗口

    socket服务器代码 import sys,os,time,_thread from socket import * class Server(object): def __init__(self) ...