MySQL提示启动成功,实际进程并没有起来

一、概括:

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

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

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

二、详情:

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

[email protected] 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,发现缺少数据文件

[[email protected] bin]# vim /var/log/mariadb/mariadb.log
2019-06-15T01:38:41.969191Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-15T01:38:41.969334Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-06-15T01:38:41.969372Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.22) starting as process 32707 ...
2019-06-15T01:38:41.976201Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-06-15T01:38:41.976243Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-06-15T01:38:41.976249Z 0 [Note] InnoDB: Uses event mutexes
2019-06-15T01:38:41.976267Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2019-06-15T01:38:41.976272Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-06-15T01:38:41.976277Z 0 [Note] InnoDB: Using Linux native AIO
2019-06-15T01:38:41.976564Z 0 [Note] InnoDB: Number of pools: 1
2019-06-15T01:38:41.976689Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-06-15T01:38:41.978521Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-06-15T01:38:41.988017Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-06-15T01:38:41.991091Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-06-15T01:38:42.001066Z 0 [Note] InnoDB: The first innodb_system data file ‘ibdata1‘ did not exist. A new tablespace will be created!
2019-06-15T01:38:42.001400Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2019-06-15T01:38:42.001411Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2019-06-15T01:38:42.001417Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2019-06-15T01:38:42.001421Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2019-06-15T01:38:42.001427Z 0 [ERROR] InnoDB: Cannot open datafile ‘./ibdata1‘
2019-06-15T01:38:42.001433Z 0 [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!
2019-06-15T01:38:42.001439Z 0 [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.
2019-06-15T01:38:42.602600Z 0 [ERROR] Plugin ‘InnoDB‘ init function returned error.
2019-06-15T01:38:42.602658Z 0 [ERROR] Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed.
2019-06-15T01:38:42.602666Z 0 [ERROR] Failed to initialize builtin plugins.
2019-06-15T01:38:42.602670Z 0 [ERROR] Aborting

2019-06-15T01:38:42.602679Z 0 [Note] Binlog end
2019-06-15T01:38:42.603033Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

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

[[email protected] mysql]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

[[email protected] mysql]# cd /var/lib/mysql/data/ibdata1
  -bash: cd: /var/lib/mysql/data/ibdata1: No such file or directory

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

[[email protected] 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,发现端口一会就没了

[[email protected] 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 文件

2019-06-15T01:49:41.178424Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-15T01:49:41.178562Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-06-15T01:49:41.178599Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.22) starting as process 2650 ...
2019-06-15T01:49:41.184805Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-06-15T01:49:41.184848Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-06-15T01:49:41.184854Z 0 [Note] InnoDB: Uses event mutexes
2019-06-15T01:49:41.184860Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2019-06-15T01:49:41.184864Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-06-15T01:49:41.184869Z 0 [Note] InnoDB: Using Linux native AIO
2019-06-15T01:49:41.185282Z 0 [Note] InnoDB: Number of pools: 1
2019-06-15T01:49:41.185458Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-06-15T01:49:41.187568Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-06-15T01:49:41.197993Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-06-15T01:49:41.202453Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-06-15T01:49:41.330706Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-06-15T01:49:41.338353Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 360871592
2019-06-15T01:49:41.338438Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 360871601
2019-06-15T01:49:41.338470Z 0 [Note] InnoDB: Database was not shutdown normally!
2019-06-15T01:49:41.338490Z 0 [Note] InnoDB: Starting crash recovery.
2019-06-15T01:49:43.702763Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-06-15T01:49:43.702868Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-06-15T01:49:43.702998Z 0 [Note] InnoDB: Setting file ‘./ibtmp1‘ size to 12 MB. Physically writing the file full; Please wait ...
2019-06-15T01:49:43.831707Z 0 [Note] InnoDB: File ‘./ibtmp1‘ size is now 12 MB.
2019-06-15T01:49:43.836313Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-06-15T01:49:43.836353Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-06-15T01:49:43.838015Z 0 [Note] InnoDB: Waiting for purge to start
2019-06-15T01:49:43.888404Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 360871601
2019-06-15T01:49:43.890016Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql/data/ib_buffer_pool
2019-06-15T01:49:43.916045Z 0 [Note] Plugin ‘FEDERATED‘ is disabled.
2019-06-15T01:49:43.964452Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190615  9:49:43
2019-06-15T01:49:44.009629Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2019-06-15T01:49:44.009838Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL_CTX_set_default_verify_paths failed
2019-06-15T01:49:44.010380Z 0 [Note] Server hostname (bind-address): ‘*‘; port: 3306
2019-06-15T01:49:44.010529Z 0 [Note] IPv6 is available.
2019-06-15T01:49:44.010552Z 0 [Note]   - ‘::‘ resolves to ‘::‘;
2019-06-15T01:49:44.010588Z 0 [Note] Server socket created on IP: ‘::‘.
2019-06-15T01:49:44.010733Z 0 [ERROR] Could not create unix socket lock file /var/lib/mysql/mysql.sock.lock.
2019-06-15T01:49:44.010746Z 0 [ERROR] Unable to setup unix socket lock file.
2019-06-15T01:49:44.010755Z 0 [ERROR] Aborting

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

[[email protected] 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/
[[email protected] mysql]# ll /var/lib/
total 4
……
drwxr-xr-x   2 mysql   mysql     47 Jun 15 09:53 mysql
……

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

[[email protected] 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  
[[email protected] mysql]# vim /var/log/mariadb/mariadb.log2019-06-15T01:49:44.010780Z 0 [Note] Binlog end
2019-06-15T01:49:44.010938Z 0 [Note] Shutting down plugin ‘ngram‘
2019-06-15T01:49:44.010973Z 0 [Note] Shutting down plugin ‘ARCHIVE‘
2019-06-15T01:49:44.010984Z 0 [Note] Shutting down plugin ‘partition‘
2019-06-15T01:49:44.010992Z 0 [Note] Shutting down plugin ‘BLACKHOLE‘
2019-06-15T01:49:44.011002Z 0 [Note] Shutting down plugin ‘PERFORMANCE_SCHEMA‘
2019-06-15T01:49:44.011161Z 0 [Note] Shutting down plugin ‘CSV‘
2019-06-15T01:49:44.011175Z 0 [Note] Shutting down plugin ‘MEMORY‘
2019-06-15T01:49:44.011196Z 0 [Note] Shutting down plugin ‘MRG_MYISAM‘
2019-06-15T01:49:44.011216Z 0 [Note] Shutting down plugin ‘MyISAM‘
2019-06-15T01:49:44.011786Z 0 [Note] Shutting down plugin ‘INNODB_SYS_VIRTUAL‘
2019-06-15T01:49:44.011817Z 0 [Note] Shutting down plugin ‘INNODB_SYS_DATAFILES‘
2019-06-15T01:49:44.011833Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESPACES‘
2019-06-15T01:49:44.011838Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN_COLS‘
2019-06-15T01:49:44.011842Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN‘
2019-06-15T01:49:44.011846Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FIELDS‘
2019-06-15T01:49:44.011851Z 0 [Note] Shutting down plugin ‘INNODB_SYS_COLUMNS‘
2019-06-15T01:49:44.011855Z 0 [Note] Shutting down plugin ‘INNODB_SYS_INDEXES‘
2019-06-15T01:49:44.011859Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESTATS‘
2019-06-15T01:49:44.011864Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLES‘
2019-06-15T01:49:44.011868Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_TABLE‘
2019-06-15T01:49:44.011872Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_CACHE‘
2019-06-15T01:49:44.011876Z 0 [Note] Shutting down plugin ‘INNODB_FT_CONFIG‘
2019-06-15T01:49:44.011880Z 0 [Note] Shutting down plugin ‘INNODB_FT_BEING_DELETED‘
2019-06-15T01:49:44.011885Z 0 [Note] Shutting down plugin ‘INNODB_FT_DELETED‘
2019-06-15T01:49:44.011889Z 0 [Note] Shutting down plugin ‘INNODB_FT_DEFAULT_STOPWORD‘
2019-06-15T01:49:44.011893Z 0 [Note] Shutting down plugin ‘INNODB_METRICS‘
2019-06-15T01:49:44.011897Z 0 [Note] Shutting down plugin ‘INNODB_TEMP_TABLE_INFO‘
2019-06-15T01:49:44.011901Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_POOL_STATS‘
2019-06-15T01:49:44.011906Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE_LRU‘
2019-06-15T01:49:44.011910Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE‘
2019-06-15T01:49:44.011914Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX_RESET‘
2019-06-15T01:49:44.011919Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX‘
2019-06-15T01:49:44.011923Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM_RESET‘
2019-06-15T01:49:44.011927Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM‘
2019-06-15T01:49:44.011947Z 0 [Note] Shutting down plugin ‘INNODB_CMP_RESET‘
2019-06-15T01:49:44.011952Z 0 [Note] Shutting down plugin ‘INNODB_CMP‘
2019-06-15T01:49:44.011956Z 0 [Note] Shutting down plugin ‘INNODB_LOCK_WAITS‘
2019-06-15T01:49:44.011961Z 0 [Note] Shutting down plugin ‘INNODB_LOCKS‘
2019-06-15T01:49:44.011965Z 0 [Note] Shutting down plugin ‘INNODB_TRX‘
2019-06-15T01:49:44.011969Z 0 [Note] Shutting down plugin ‘InnoDB‘
2019-06-15T01:49:44.012134Z 0 [Note] InnoDB: FTS optimize thread exiting.
2019-06-15T01:49:44.012281Z 0 [Note] InnoDB: Starting shutdown...
2019-06-15T01:49:44.112614Z 0 [Note] InnoDB: Dumping buffer pool(s) to /usr/local/mysql/data/ib_buffer_pool
2019-06-15T01:49:44.117111Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 190615  9:49:44
2019-06-15T01:49:45.836575Z 0 [Note] InnoDB: Shutdown completed; log sequence number 360872741
2019-06-15T01:49:45.839893Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-06-15T01:49:45.839924Z 0 [Note] Shutting down plugin ‘sha256_password‘
2019-06-15T01:49:45.839932Z 0 [Note] Shutting down plugin ‘mysql_native_password‘
2019-06-15T01:49:45.840120Z 0 [Note] Shutting down plugin ‘binlog‘
2019-06-15T01:49:45.840407Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

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

原文地址:https://www.cnblogs.com/leozhanggg/p/11027533.html

时间: 2024-11-07 09:56:35

MySQL提示启动成功,实际进程并没有起来的相关文章

解决php工具箱(phpStudy)Apache启动成功,MySql无法启动的问题

今天花了两个多小时的时间给别人捣鼓php工具箱,自己都很惊讶. 由于xampp中的不太适合新手刚开始学php使用,所以我给她安装了php工具箱,这是个可以切换版本的软件,我很推荐,而且不需要配置! 不过很让人头疼的是Apache正常启动,,MySql就是无法启动,百度上说的也不咋有用(不一竿子打死,最终解决办法的前身还是百度的),百度上大多数是说的端口问题,Apache是80,MySql是3306,然而检测端口占用信息是安全的,也就是说端口不是致命的. 我说我遇到的这种情况:1.注册表里没有My

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

1.首先以管理员身份启动cmd,要不然服务禁止访问. 2.然后在cmd中输入 mysqld --remove mysql或者mysqld --remove mysql57来移除服务. 3.然后进入MySQL安装目录中找到data文件,清空其中全部文件.我的目录是D:\MySQL\MySQL Server 5.7\data,没有data文件自己建一个. 4.接下来注册服务,mysqld -install. 5.然后开始初始化,mysqld --initialize,(第4步和第5步忘记了先后顺序,

net start mysql提示:服务名无效

1.win+R打开运行窗口,输入services.msc 2.在其中查看mysql的服务名,我的是MySQL55 3.以管理员身份打开cmd,输入net start MySQL55 出现下图,代表mysql服务启动成功. 注: 必须以管理员身份运行mysql服务,否则会提示:发生系统错误5,拒绝访问.

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

MySQL Study之--Mysql无法启动"mysql.host" 系统环境: 操作系统:RedHat EL55 DB Soft:  Mysql 5.6.4-m7 通过源代码包安装mysql后,在启动mysqld时出现错误: [[email protected] mysql]# bin/mysqld_safe & [1] 15846 [[email protected] mysql]# 150610 17:04:36 mysqld_safe Logging to '/usr

服务器异常断电导致windows下mysql服务启动报1067错误

1.进入在D:\candaoserver\mysql\下面的my.ini中添加一行 innodb_force_recovery =1 启动mysql,启动成功开用工具连接数据库成功,但数据库里面有的表打不开报1146 2.再进入在D:\candaoserver\mysql\下面的my.ini中添加一行 lower_case_table_names=1 重启mysql,启动成功开用工具连接数据库成功,表可以都打开了 3.再进入在D:\candaoserver\mysql\下面的my.ini中将之前

net start mysql启动mysql,提示发生系统错误 5 拒绝访问 解决方法

解决问题方法如下: 在dos下运行net  start mysql 不能启动mysql!提示发生系统错误 5:拒绝访问!切换到管理员模式就可以启动了.所以我们要以管理员身份来运行cmd程序来启动mysql. 那么如何用管理员身份来运行cmd程序呢? 0.在C:\Windows\System32下面找到cmd.exe,右键附加到开始菜单 1.右键单击cmd选择"附到[开始]菜单(U)";这是就可以到开始菜单上找到cmd了, 2.右击选择属性,选择快捷方式,选择以管理员身份运行,再单击确定

mysql集群无法启动成功

场景:两台数据库运行一段时间后发现集群挂了,一台服务正常,一台不正常. 日志如下: [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace mysql/innodb_table_stats uses space ID: 1 at filepath: ./mysql/innodb_table_stats.ibd. Cannot open tablespace testdb/dr_ac

Spring boot启动成功后输出提示

添加logback-spring.xml,将log输出到文件,控制台输出的level改为error因此只会出处banner src/main/resources/banner.txt的内容为 start... 但是输出完banner后,spring boot并没有启动完毕 因此,我想在Spring boot启动成功后输出提示 有两种方式 1.实现 ApplicationRunnerImpl eg: package com.example.demo.configure; import org.sp

cmd中输入net start mysql 提示:服务名无效或者MySQL正在启动 MySQL无法启动

错误如图: 错误原因是:因为net start +服务名,启动的是win下注册的服务.此时,系统中并没有注册mysql到服务中.即当前路径下没有mysql服务. 解决办法:1. 来到MySQL的安装路径下bin 2. 在命令行中输入mysqld --install(成功:出现Service successfully install代表你已经安装成功,) 如果不成功,出现Install/Remove of the Service Denied!,则需要用管理员的身份运行DOS窗口,这样就可以成功了