密码无法登录问题:

在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. python 关闭垃圾回收

    import gc gc.disable() http://blog.csdn.net/aixiaohei/article/details/6446869

  2. nyoj 0269 VF(dp)

    nyoj 0269 VF 意思大致为从1-10^9数中找到位数和为s的个数 分析:利用动态规划思想,一位一位的考虑,和s的范围为1-81 状态定义:dp[i][j] = 当前所有i位数的和为j的个数 ...

  3. jquery 共用函数

    ready()方法 $(doxument).ready(fucntion(){ }) $().ready(function(){ }) $(function(){ }) 当文档加载后激活函数:     ...

  4. shell script auto generate the relevant header information

    first : add follow context in   /etc/vim/vimrc set ignorecaseset cursorlineset autoindentautocmd Buf ...

  5. js将接口返回的数据序列化

    <div style={{marginLeft: '80px'}}>                     <pre>                         {th ...

  6. tomcat启动超时_tomcat was unable to start within

    参考: http://jingyan.baidu.com/article/64d05a025c9969de55f73b23.html 首先,你得确认下你的数据库连接,尤其是在多个服务器之间转换或者服务 ...

  7. 稀疏 部分 Checkout

    To easily select only the items you want for the checkout and force the resulting working copy to ke ...

  8. day039 数据库索引

    今日内容: 1.为什么要有索引 简而言之,索引出现的意义是为了更方便,更快速的查询数据. 什么是索引 索引在mysql中也叫''键''或'key'(primary key unique key,ind ...

  9. 【转】Java中static关键字用法总结

    1.     静态方法 通常,在一个类中定义一个方法为static,那就是说,无需本类的对象即可调用此方法 声明为static的方法有以下几条限制: · 它们仅能调用其他的static 方法. · 它 ...

  10. web service基础知识

    Web服务基础 用户访问网站的基本流程 我们每天都会用web客户端上网,浏览器就是一个web客户端,例如谷歌浏览器,以及火狐浏览器等. 当我们输入www.oldboyedu.com/时候,很快就能看到 ...