密码无法登录问题:

在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

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. post和get的使用场景和区别

    使用场景: 区别: ①传送方式不同:get通过地址栏传输,post通过报文传输. ②get产生一个TCP数据包,post产生两个数据包,对于get方式的请求,浏览器会把http header和data ...

  2. Notes on Large-scale Video Classification with Convolutional Neural Networks

    Use bigger datasets for CNN in hope of better performance. A new data set for sports video classific ...

  3. linux command mktemp

    Linux command mktemp [Purpose]        Learning linux command mktemp to create a temporary file or di ...

  4. net资源1

    .net core 例子 https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals C#中使用Spire.docx操作Wor ...

  5. python -input用户输入

    #接收用户输入信息用input就可以了 #还有输入密码的,也就是隐藏的,pycharm中不好用,要到命令行去 import getpass name = input('name:') age = in ...

  6. 《Python》模块和包

    一.模块 1.什么是模块: 一个模块就是一个包含了Python定义和声明的文件,文件名就是模块名字加上.py的后缀. 但其实import加载的模块分为四个通用类别: 1.使用Python编写的代码(. ...

  7. 关于iOS构建版本

    1.Build Active Architecture Only 设置 Build Active Architecture Only 设置为NO的时候,会编译支持的所有的版本 设置为YES的时候,是为 ...

  8. linux 在执行命令过程中,反单引号(`)这个符号代表的意义为何?

    在一串命令中,在`之内的命令将会被先执行,而且执行出来的结果将作为外部的输入信息.例如:uname -r 会显示出目前的内核版本,而我们的内核版本在/lib/modules里面,因此.你可以先执行un ...

  9. VSTO:使用C#开发Excel、Word【1】

    <Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath >——By Eric C ...

  10. SQL-14 从titles表获取按照title进行分组,每组个数大于等于2,给出title以及对应的数目t。 注意对于重复的emp_no进行忽略。

    题目描述 从titles表获取按照title进行分组,每组个数大于等于2,给出title以及对应的数目t.注意对于重复的emp_no进行忽略.CREATE TABLE IF NOT EXISTS &q ...