一、概括:

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. gulp遇到错误:The following tasks did not complete: default Did you forget to signal async completion?

    运行之后会像下面一样报这个错误,因为事按着一个视频来写的,所以 原本的gulpfile.js如下 const gulp = require('gulp') gulp.task('default',() ...

  2. alibaba/flutter_boost

    flutterBoost使用笔记 新一代Flutter-Native混合解决方案. FlutterBoost是一个Flutter插件,它可以轻松地为现有原生应用程序提供Flutter混合集成方案.Fl ...

  3. Centos7脚本一键优化

    我把优化centos7的脚本分享给大家,建议刚安装完服务器的朋友执行如下优化脚本 [root@test2 yum.repos.d]# cat centos7.sh #!/bin/bash #autho ...

  4. Hive時間函數-年份相加減

    Hive時間函數-年份相加減 目前為止搜了很多资料,都没有找到Hive关于时间 年份,月份的处理信息,所以就自己想办法截取啦 本来是用了概数,一年365天去取几年前的日期,后来测试的发现不够精准,然后 ...

  5. 自学Java编程,如何混到一个7k薪资实习生的岗位

    现在Java软件开发的专业一直都是热门,有很多专业的学生,比如电子.机械.会计.土木等等专业由于专业本身没有更高的提升空间,所以现在的年轻人更加喜欢做一些科技前沿的工作,毕竟现在接触的都是电子产品.而 ...

  6. Java程序员月薪三万,需要技术达到什么水平?

    最近跟朋友在一起聚会的时候,提了一个问题,说 Java 程序员如何能月薪达到二万,技术水平需要达到什么程度?人回答说这只能是大企业或者互联网企业工程师才能拿到.也许是的,小公司或者非互联网企业拿二万的 ...

  7. 利用Fiddler对Jmeter的请求进行抓包

    前言 有时候,为了得到更详细的请求结果,我们可能需要使用Fiddler结合Jmeter来抓包分析,从而更好的辅助测试. 遇到的问题 这里以一个获取学生信息的接口为例进行说明. 当我在Jmeter里按接 ...

  8. C# 使用TopShelf实现Windows服务部署

    一.TopShelf介绍 topShelf是创建Windows服务的一种方式,可以方便管理应用服务,最大广泛应用于,数据实时接收,定时推送等. 二.TopShelf使用 1.安装 TopShelf程序 ...

  9. vs2017 C# ActiveX浏览器插件 创建 发布 C# windows窗体控件库(.NET Framework)注意事项

    vs2017需要安装插 插件下载地址:https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.Micro ...

  10. Ubuntu 无法打开系统设置

    最近不知道咋搞得,导致系统设置打不开,可能是系统输入法的问题吧,运行以下命令: sudo apt-get install gnome-control-center