[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. ssh登录实现

    工程目录 配置文件详解 Spring的applicationContext.xml文件 <span ><?xml version="1.0" encoding=& ...

  2. MySQL prompt命令

    修改提示符,设置后挺方便的 例如: 几个好用的参数 \d 当前数据库 \u 当前用户 \h 当前主机 更多参数可以参考mysol官方文档 参考文档:https://dev.mysql.com/doc/ ...

  3. 一些在线开发手册api文档收藏

    java JavaSE8 api:https://docs.oracle.com/javase/8/docs/api/ JavaSE7 api:http://docs.oracle.com/javas ...

  4. HDU-3790 最短路最小花费

    判断路径相等时的情况 #include <iostream> #include <cstring> #include <algorithm> #include &l ...

  5. js小数转分数-近似递归

    精度为小数两位,提高精度可把 toFixed(2)和100同时修改: function decimalsToFractional(decimals){ const formatDecimals = d ...

  6. mysqlcppconn之ConnectOptionsMap的使用

    由来 继上一篇文章, 发现之前写的一篇文章中断线重连部分是错误的, 也是现在翻阅了源码才知道 想要自动重连, 必须使用ConnectOptionsMap才可以 但由于官方代码没有做好导出部分的处理, ...

  7. seo搜索引擎优化

    1.logo 图片换文字 比较好的方法,就是用背景图呈现,标签中写文字,因为文字能被搜索引擎抓取.(background) <h1><a href="##"> ...

  8. mvn 打包命令

    mvn install & package:package是把jar打到本项目的target下,而install时把target下的jar安装到本地仓库,供其他项目使用. mvn clean ...

  9. Ten C++11 Features Every C++ Developer Should Use

    原版:http://www.codeproject.com/Articles/570638/Ten-Cplusplus-Features-Every-Cplusplus-Developer 译版:ht ...

  10. 设计模式:享元(FlyWeight)模式

    设计模式:享元(FlyWeight)模式 一.前言     享元(FlyWeight)模式顾名思义,既是轻量级的,原因就是享元,共享元素,这里的元素指的是对象.如何共享对象,那就是在检测对象产生的时候 ...