[root@localhost ~]# systemctl start mysqld       启动失败

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

查看系统日志报错为:

May 29 19:04:53 localhost mysqld: 2018-05-29T11:04:53.723812Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
May 29 19:04:53 localhost mysqld: 2018-05-29T11:04:53.723862Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
May 29 19:04:53 localhost mysqld: 2018-05-29T11:04:53.723871Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325440Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325475Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325483Z 0 [ERROR] Failed to initialize builtin plugins.
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325485Z 0 [ERROR] Aborting

报错原因大致为:你的数据文件不可写

导致原因:yum安装的mysql的拥有者是root,而mysql要求执行身份为mysql,权限问题导致数据文件不可写

  解决方法如下:

[root@localhost ~]# chown -R mysql /var/lib/mysql

[root@localhost ~]# systemctl start mysqld

[root@localhost ~]# tailf /var/log/messages &

日志打印:

May 29 19:09:15 localhost mysqld: Version: '5.7.22'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

启动成功

登录 MySQL,此时不需要密码,直接回车:

# mysql -u root -p

更改 root 密码 为 123456

mysql> use mysql;
mysql> update user set authentication_string=password("123456") where user='root';
mysql> flush privileges; # 刷新权限,不刷新的话可能导致mysql回车直接就会登录

注意密码字段名 5.7 版本的是 authentication_string,之前的为 password

修改完后,记得注释掉 my.cnf 中的 skip-grant-tables 参数,重启 MySQL 服务,就可以用你设置的密码登录了。

centos7 yum安装mysql后启动不起来问题的更多相关文章

  1. yum安装mysql后root用户的临时密码

    1.查看root用户临时随机密码 yum 安装mysql后,无法通过空密码登录数据库,如下: [root@ mysql]# mysql -u root -p Enter password: ERROR ...

  2. Centos7 yum安装mysql

    参考此文档:http://www.jb51.net/article/116032.htm http://www.jb51.net/article/95399.htm 1.在官网下载mysql57-co ...

  3. centos7 yum 安装mysql

    介绍在CentOS7上yum安装数据库服务器MySQL Community Server 5.7的方法. 准备 CentOS7默认安装了和MySQL有兼容性的MariaDB数据库,在我们安装MySQL ...

  4. CentOS7用yum安装MySQL与启动

    首先CentOS7 已经不支持mysql,因为收费了你懂得,所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以需要先卸载掉mariadb,以下为卸载mariadb,安 ...

  5. centos7 yum安装mysql | mariaDb

    mysql解释: mysql数据库是最常用的一种数据库,下面我来在centos7的迷你版上安装一下mysql.绝对纯净的环境哦 centos:    CentOS-7-x86_64-Minimal-1 ...

  6. yum安装mysql后没有mysqld

    在Centos中用命令 yum install mysql安装数据库,但装完后运行mysqld启动mysql的时候提示找不到,通过 find / | grep mysqld 也没找到mysqld的目录 ...

  7. centos7 yum 安装 mysql

    CentOS7默认数据库是mariadb,配置等用着不习惯,因此决定改成mysql,但是CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1 ...

  8. Centos7 yum安装mysql(完整版)

    1.下载mysql 地址:https://dev.mysql.com/downloads/repo/yum/.选择对应版本下载.

  9. centos-7 yum装docker-ce后启动失败

    相关版本: centos-7:   CentOS Linux release 7.0.1406 (Core) docker-ce: Docker version 18.03.0-ce, build 0 ...

随机推荐

  1. git提交空文件夹和删除远程文件

    git提交空文件夹 在文件夹中创建 .gitkeep 文件,文件内容如下 # Ignore everything in this directory * # Except this file !.gi ...

  2. Shiro登录校验

    shiro是一种权限认证框架,实现一个简单的登录鉴权: 1.控制器层: @Controller @RequestMapping("/blogger") public class B ...

  3. 七、集成swagger2

    1.添加依赖 <!-- swager2 --> <dependency> <groupId>io.springfox</groupId> <art ...

  4. Elasticsearch全文检索工具入门

    Elasticsearch全文检索工具入门: 1.下载对应系统版本的文件 elasticsearch-2.4.0.zip 1.1运行elasticsearch-2.4.0\elasticsearch- ...

  5. Scrapy框架的使用

    Scrapy框架的安装 pip install pywin32 下载 Twisted 包       pip install Twisted包的路径 pip insatll scrapy Scrapy ...

  6. Python入门-初始面向对象

    之前我们代码基本上都是面向过程的,今天我们就来初始一下python中一个重要的内容:面向对象 一.面向对象和面向过程(重点理解) 1.面向过程: 一切以事物的流程为核心. 核心是"过程&qu ...

  7. js表单快速取值/赋值 快速生成下拉框

    1.表单取值/赋值公共方法 //表单序列化:文本框的name字段和数据源一致<form id="myForm" onsubmit="return false;&qu ...

  8. JSTL数据格式化

    日期表示 <fmt:formatDate value="${DATE1}" pattern="yyyy-MM-dd hh:mm:ss" type=&quo ...

  9. C#虚基类继承与接口的区别

    类:定义新的数据类型以及这些新的数据类型进行相互操作的方法 定义方式: class Cat { } class Cat:object { } C#中所有的类都是默认由object类派生来的,显示指定或 ...

  10. 转 linux screen 命令详解

    一.背景 系统管理员经常需要SSH 或者telent 远程登录到Linux 服务器,经常运行一些需要很长时间才能完成的任务,比如系统备份.ftp 传输等等.通常情况下我们都是为每一个这样的任务开一个远 ...