一、概括:

1、查看运行日志 vim /var/log/mariadb/mariadb.log

2、修改配置文件 vim /etc/my.cnf

3、修改文件权限 chown mysql.mysql -R /var/lib/mysql/

二、详情:

首先我们尝试启动MySQL,发现没有MySQL进程

root@centos74-tmp sbin]# pwd
/usr/local/mysql/bin
[root@centos74-tmp bin]# service mysqld start
Starting MySQL SUCCESS!
[root@centos74-tmp bin]# pgrep -af mysql

我们查看日志 mariadb.log,发现缺少数据文件

[root@centos74-tmp bin]# vim /var/log/mariadb/mariadb.log
--15T01::.969191Z [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
--15T01::.969334Z [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
--15T01::.969372Z [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.) starting as process ...
--15T01::.976201Z [Note] InnoDB: PUNCH HOLE support available
--15T01::.976243Z [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
--15T01::.976249Z [Note] InnoDB: Uses event mutexes
--15T01::.976267Z [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
--15T01::.976272Z [Note] InnoDB: Compressed tables use zlib 1.2.
--15T01::.976277Z [Note] InnoDB: Using Linux native AIO
--15T01::.976564Z [Note] InnoDB: Number of pools:
--15T01::.976689Z [Note] InnoDB: Using CPU crc32 instructions
--15T01::.978521Z [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = , chunk size = 128M
--15T01::.988017Z [Note] InnoDB: Completed initialization of buffer pool
--15T01::.991091Z [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
--15T01::.001066Z [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
--15T01::.001400Z [ERROR] InnoDB: Operating system error number in a file operation.
--15T01::.001411Z [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
--15T01::.001417Z [ERROR] InnoDB: Operating system error number in a file operation.
--15T01::.001421Z [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
--15T01::.001427Z [ERROR] InnoDB: Cannot open datafile './ibdata1'
--15T01::.001433Z [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
--15T01::.001439Z [ERROR] InnoDB: InnoDB Database creation was aborted with error Cannot open a file. You may need to delete the ibdata1 file before trying to start up again.
--15T01::.602600Z [ERROR] Plugin 'InnoDB' init function returned error.
--15T01::.602658Z [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
--15T01::.602666Z [ERROR] Failed to initialize builtin plugins.
--15T01::.602670Z [ERROR] Aborting --15T01::.602679Z [Note] Binlog end
--15T01::.603033Z [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

通过配置文件 my.cnf 查看数据文件 ibdata1 路径 ,发现实际文件不在

[root@centos74-tmp mysql]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

[root@centos74-tmp mysql]# cd /var/lib/mysql/data/ibdata1
  -bash: cd: /var/lib/mysql/data/ibdata1: No such file or directory

通过 find 命令找到数据文件 ibdata1 实际目录,并修改配置文件 my.cnf

[root@centos74-tmp mysql]# find / -name ibdata*
/usr/local/mysql/data/ibdata1
[root@centos74-tmp mysql]# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data/
socket=/var/lib/mysql/mysql.sock

再次尝试启动MySQL,发现端口一会就没了

[root@centos74-tmp mysql]# service mysqld start
Starting MySQL SUCCESS!
[root@centos74-tmp bin]# netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::4118 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
[root@centos74-tmp bin]# netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
tcp6 0 0 :::4118 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN

再次查看MySQL日志,发现不能创建 mysql.sock.lock 文件

--15T01::.178424Z  [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
--15T01::.178562Z [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
--15T01::.178599Z [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.) starting as process ...
--15T01::.184805Z [Note] InnoDB: PUNCH HOLE support available
--15T01::.184848Z [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
--15T01::.184854Z [Note] InnoDB: Uses event mutexes
--15T01::.184860Z [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
--15T01::.184864Z [Note] InnoDB: Compressed tables use zlib 1.2.
--15T01::.184869Z [Note] InnoDB: Using Linux native AIO
--15T01::.185282Z [Note] InnoDB: Number of pools:
--15T01::.185458Z [Note] InnoDB: Using CPU crc32 instructions
--15T01::.187568Z [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = , chunk size = 128M
--15T01::.197993Z [Note] InnoDB: Completed initialization of buffer pool
--15T01::.202453Z [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
--15T01::.330706Z [Note] InnoDB: Highest supported file format is Barracuda.
--15T01::.338353Z [Note] InnoDB: Log scan progressed past the checkpoint lsn
--15T01::.338438Z [Note] InnoDB: Doing recovery: scanned up to log sequence number
--15T01::.338470Z [Note] InnoDB: Database was not shutdown normally!
--15T01::.338490Z [Note] InnoDB: Starting crash recovery.
--15T01::.702763Z [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
--15T01::.702868Z [Note] InnoDB: Creating shared tablespace for temporary tables
--15T01::.702998Z [Note] InnoDB: Setting file './ibtmp1' size to MB. Physically writing the file full; Please wait ...
--15T01::.831707Z [Note] InnoDB: File './ibtmp1' size is now MB.
--15T01::.836313Z [Note] InnoDB: redo rollback segment(s) found. redo rollback segment(s) are active.
--15T01::.836353Z [Note] InnoDB: non-redo rollback segment(s) are active.
--15T01::.838015Z [Note] InnoDB: Waiting for purge to start
--15T01::.888404Z [Note] InnoDB: 5.7. started; log sequence number
--15T01::.890016Z [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql/data/ib_buffer_pool
--15T01::.916045Z [Note] Plugin 'FEDERATED' is disabled.
--15T01::.964452Z [Note] InnoDB: Buffer pool(s) load completed at ::
--15T01::.009629Z [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
--15T01::.009838Z [Warning] Failed to set up SSL because of the following SSL library error: SSL_CTX_set_default_verify_paths failed
--15T01::.010380Z [Note] Server hostname (bind-address): '*'; port:
--15T01::.010529Z [Note] IPv6 is available.
--15T01::.010552Z [Note] - '::' resolves to '::';
--15T01::.010588Z [Note] Server socket created on IP: '::'.
--15T01::.010733Z [ERROR] Could not create unix socket lock file /var/lib/mysql/mysql.sock.lock.
--15T01::.010746Z [ERROR] Unable to setup unix socket lock file.
--15T01::.010755Z [ERROR] Aborting

查看文件夹权限,发现属主为root,修改为mysql

[root@centos74-tmp mysql]# ll /var/lib/
total 4
……
drwxr-xr-x 2 root root 6 Jun 15 09:44 mysql
……
[root@centos74-tmp mysql]# chown mysql.mysql -R /var/lib/mysql/
[root@centos74-tmp mysql]# ll /var/lib/
total 4
……
drwxr-xr-x 2 mysql mysql 47 Jun 15 09:53 mysql
……

再次尝试重启MySQL,发现启动成功!!!

[root@centos74-tmp mysql]# service mysqld start
service mysqld start
Starting MySQL. SUCCESS!
[root@centos74-tmp mysql]# netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::4118 :::* LISTEN
tcp6 0 0 :::22
[root@centos74-tmp mysql]# vim /var/log/mariadb/mariadb.log
2019--15T01::.010780Z [Note] Binlog end
--15T01::.010938Z [Note] Shutting down plugin 'ngram'
--15T01::.010973Z [Note] Shutting down plugin 'ARCHIVE'
--15T01::.010984Z [Note] Shutting down plugin 'partition'
--15T01::.010992Z [Note] Shutting down plugin 'BLACKHOLE'
--15T01::.011002Z [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
--15T01::.011161Z [Note] Shutting down plugin 'CSV'
--15T01::.011175Z [Note] Shutting down plugin 'MEMORY'
--15T01::.011196Z [Note] Shutting down plugin 'MRG_MYISAM'
--15T01::.011216Z [Note] Shutting down plugin 'MyISAM'
--15T01::.011786Z [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
--15T01::.011817Z [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
--15T01::.011833Z [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
--15T01::.011838Z [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
--15T01::.011842Z [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
--15T01::.011846Z [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
--15T01::.011851Z [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
--15T01::.011855Z [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
--15T01::.011859Z [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
--15T01::.011864Z [Note] Shutting down plugin 'INNODB_SYS_TABLES'
--15T01::.011868Z [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
--15T01::.011872Z [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
--15T01::.011876Z [Note] Shutting down plugin 'INNODB_FT_CONFIG'
--15T01::.011880Z [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
--15T01::.011885Z [Note] Shutting down plugin 'INNODB_FT_DELETED'
--15T01::.011889Z [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
--15T01::.011893Z [Note] Shutting down plugin 'INNODB_METRICS'
--15T01::.011897Z [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
--15T01::.011901Z [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
--15T01::.011906Z [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
--15T01::.011910Z [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
--15T01::.011914Z [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
--15T01::.011919Z [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
--15T01::.011923Z [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
--15T01::.011927Z [Note] Shutting down plugin 'INNODB_CMPMEM'
--15T01::.011947Z [Note] Shutting down plugin 'INNODB_CMP_RESET'
--15T01::.011952Z [Note] Shutting down plugin 'INNODB_CMP'
--15T01::.011956Z [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
--15T01::.011961Z [Note] Shutting down plugin 'INNODB_LOCKS'
--15T01::.011965Z [Note] Shutting down plugin 'INNODB_TRX'
--15T01::.011969Z [Note] Shutting down plugin 'InnoDB'
--15T01::.012134Z [Note] InnoDB: FTS optimize thread exiting.
--15T01::.012281Z [Note] InnoDB: Starting shutdown...
--15T01::.112614Z [Note] InnoDB: Dumping buffer pool(s) to /usr/local/mysql/data/ib_buffer_pool
--15T01::.117111Z [Note] InnoDB: Buffer pool(s) dump completed at ::
--15T01::.836575Z [Note] InnoDB: Shutdown completed; log sequence number
--15T01::.839893Z [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
--15T01::.839924Z [Note] Shutting down plugin 'sha256_password'
--15T01::.839932Z [Note] Shutting down plugin 'mysql_native_password'
--15T01::.840120Z [Note] Shutting down plugin 'binlog'
--15T01::.840407Z [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

—— 以上仅为我个人遇到的情况,可能会有所不同,请根据实际情况,依据日志报错一个个处理。

【解决】MySQL提示启动成功,实际进程并没有起来的更多相关文章

  1. VS2017装了西红柿插件之后,启动很多次才能启动成功,进程有很多devenv.exe但是就是无法启动成功

    VS2017装了西红柿插件之后,启动很多次才能启动成功,进程有很多devenv.exe但是就是无法启动成功,这个可能是西红柿插件visual assist的问题 启动vs命令行 输入: devenv ...

  2. MySQL:解决MySQL无法启动的问题

    MySQL无法启动的原因有多种,这里是我遇到的一种情况和解决方法. 起因: 最近项目需要使用MySQL,于是想在MAC上安装一个本地的数据库,但是其实忘了已经安装过一个版本了,结果发现新的服务器怎么也 ...

  3. 解决mysql提示服务无法启动问题

    1.管理员权限打开命令,进入mysql下bin文件夹 删除根目录下data文件夹没有不用管,重新安装 2. ---------------------------------------------- ...

  4. 解决MySQL服务启动时报1067错误

    工具/原料 MySQL_5.6.24_win32 方法/步骤 当我们安装完Mysql时,如果在服务当中(可以在“运行”-->"service.msc"打开并查看)无法看到My ...

  5. docker相关----解决tomcat容器启动成功,无法访问的问题

    使用docker安装了tomcat镜像,默认为latest最新的(8.5.50版本),依据tomcat镜像创建容器并同时做了端口映射 命令为:docker run --name tomcat01 -d ...

  6. 破解windows下MySQL服务启动不了的情况下不能对其进行全然卸载的解决方式

    下面的文章主要介绍的是在MySQL服务启动不了的情况下,不能对其进行全然卸载的实际解决的方法的描写叙述,下面就是对解决MySQL服务启动不了的情况下详细方案的描写叙述,希望在你今后的学习中会对你有所帮 ...

  7. 解决Mysql因内存不足启动失败的问题

    参考:https://www.jb51.net/article/136432.htm 一.查看内存 free -h free -m 二.解决方法: 1.增加swap交换空间解决问题: dd if=/d ...

  8. 本地服务开启MySQL57提示本地计算机上MySQL服务启动后停止。。。。

    1.首先以管理员身份启动cmd,要不然服务禁止访问. 2.然后在cmd中输入 mysqld --remove mysql或者mysqld --remove mysql57来移除服务. 3.然后进入My ...

  9. MySQL Study之--Mysql无法启动“mysql.host”

    MySQL Study之--Mysql无法启动"mysql.host" 系统环境: 操作系统:RedHat EL55 DB Soft:  Mysql 5.6.4-m7 通过源代码包 ...

随机推荐

  1. 原生js入门级测试题及答案

    01.屏幕打印2000到3000之间的所有的数. <script type="text/javascript"> for (var i = 2000; i < 3 ...

  2. linux指令-date

    1.在linux中要显示日期,则可以直接输入指令date 2.如果想以这样2016/12/26的方式输出呢,那就是,Y是年份,m是月份,d是日 date +%Y/%m/%d 3.如果要显示时间,则da ...

  3. 基于C# WPF框架的贪吃蛇

    游戏开始界面 游戏开始 共有两条蛇,吃到红色食物加1分,吃到绿色毒食物减1分,知道0不减: 碰到墙壁游戏结束,碰到对方游戏结束,碰到自己游戏结束 此游戏通过Canvas画布布局,通过C#代码实现 游戏 ...

  4. Python基础-day01-2

    第一个 Python 程序 目标 第一个 HelloPython 程序 Python 2.x 与 3​​.x 版本简介 执行 Python 程序的三种方式 解释器 -- python / python ...

  5. Python面向对象-类、实例的绑定属性、绑定方法和__slots__

    绑定属性 从之前的文章中,我们知道python是动态语言——实例可以绑定任意属性. 那如果实例绑定的属性和类的属性名一样的话,会是什么情况呢? >>> class Student(o ...

  6. 使用百度大脑iOCR,快速自定义机票行程单模板识别

    1. 功能介绍百度已经推出了iOCR财会票据识别,针对财会报销场景提出的专项解决方案,可对各类财务票据.报销单.银行回单.对账单进行自动分类及结构化识别,并支持用户为固定版式的新票据/单据自定义结构化 ...

  7. Git 原理简谈

    Git 本身是一个对 reference 进行管理的数据库,reference 指的是对原始数据的引用.通过对原始数据的追踪,那么就可以做到对版本的控制.Git 使用一个 DAG 存储了整个的refe ...

  8. vue中Enter触发登录事件和javascript中Enter触发点击事件

    created(){ window.addEventListener('keydown', this.handleKeyDown, true)//开启监听键盘按下事件 } 在methods中当keyC ...

  9. 【10分钟学Spring】:(二)一文搞懂spring依赖注入(DI)

    Spring最基础的特性就是创建bean.管理bean之间的依赖关系.下面通过具体实例演示该如何装配我们应用中的bean. Spring提供了三种主要的装配机制 在xml中进行显示的配置 在Java中 ...

  10. C#构造方法(构造函数)

    构造方法特点: 一 ,与类同名 public class Product { public int ID { get; set; } public String NAME { get; set; } ...