导致mysqld无法启动的一个错误问题及解决

 更新时间:2023年02月20日 14:04:52   作者:qiuchangyong  
这篇文章主要介绍了导致mysqld无法启动的一个错误问题及解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

导致mysqld无法启动的一个错误

由于不小心删除了 /var/log/mysql/ 这个目录(这是mysql服务器用来保存log的地方),导致无法启动mysqld。

在终端输入 service mysql start 回车,输出:

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

于是在终端输入 mysqld 回车,输出:

2020-12-24T06:29:14.144840Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-12-24T06:29:14.146597Z 0 [Note] mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 2760 ...
2020-12-24T06:29:14.151841Z 0 [ERROR] Could not open file '/var/log/mysql/error.log' for error logging: Permission denied
2020-12-24T06:29:14.151990Z 0 [ERROR] Aborting
 
2020-12-24T06:29:14.152063Z 0 [Note] Binlog end
2020-12-24T06:29:14.152108Z 0 [Note] mysqld: Shutdown complete

从提示看,是无法创建error.log,于是创建/var/log/mysql,再执行 ls -l /var/log 发现mysql这个目录的用户权限和组权限都是root,这就是问题所在,需要将其都改为mysql(使用chmod和chown命令)。

mysql 启动报错问题

MySQL 启动时报错

[root@yyfwq2 bin]# service mysql start
Starting MySQL....The server quit without updating PID file (/app/data//mysqldb.pid).[FAILED]

检查日志

[root@yyfwq2 log]# cat error.log
2017-11-21T11:42:15.698749Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2017-11-21T11:42:15.698941Z 0 [Note] /app/mysql/bin/mysqld (mysqld 5.7.18-log) starting as process 7838 ...
2017-11-21T11:42:15.710334Z 0 [Note] InnoDB: PUNCH HOLE support not available
2017-11-21T11:42:15.710380Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-11-21T11:42:15.710389Z 0 [Note] InnoDB: Uses event mutexes
2017-11-21T11:42:15.710397Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2017-11-21T11:42:15.710404Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-11-21T11:42:15.710412Z 0 [Note] InnoDB: Using Linux native AIO
2017-11-21T11:42:15.710979Z 0 [Note] InnoDB: Number of pools: 1
2017-11-21T11:42:15.711154Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-11-21T11:42:15.716819Z 0 [Note] InnoDB: Initializing buffer pool, total size = 10G, instances = 8, chunk size = 128M
2017-11-21T11:42:16.845646Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-11-21T11:42:16.961424Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-11-21T11:42:16.961647Z 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 65536 pages, max 0 (relevant if non-zero) pages!
2017-11-21T11:42:16.961676Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-11-21T11:42:17.562477Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-11-21T11:42:17.562498Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-11-21T11:42:17.562511Z 0 [ERROR] Failed to initialize plugins.
2017-11-21T11:42:17.562518Z 0 [ERROR] Aborting
 
2017-11-21T11:42:17.562536Z 0 [Note] Binlog end
2017-11-21T11:42:17.562673Z 0 [Note] Shutting down plugin 'CSV'
2017-11-21T11:42:17.563197Z 0 [Note] /app/mysql/bin/mysqld: Shutdown complete
 
2017-11-21T11:46:34.437631Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2017-11-21T11:46:34.437786Z 0 [Note] /app/mysql/bin/mysqld (mysqld 5.7.18-log) starting as process 9427 ...
2017-11-21T11:46:34.446814Z 0 [Note] InnoDB: PUNCH HOLE support not available
2017-11-21T11:46:34.446875Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-11-21T11:46:34.446886Z 0 [Note] InnoDB: Uses event mutexes
2017-11-21T11:46:34.446894Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2017-11-21T11:46:34.446902Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-11-21T11:46:34.446910Z 0 [Note] InnoDB: Using Linux native AIO
2017-11-21T11:46:34.447429Z 0 [Note] InnoDB: Number of pools: 1
2017-11-21T11:46:34.447594Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-11-21T11:46:34.451429Z 0 [Note] InnoDB: Initializing buffer pool, total size = 10G, instances = 8, chunk size = 128M
2017-11-21T11:46:35.561606Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-11-21T11:46:35.666054Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-11-21T11:46:35.666901Z 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 65536 pages, max 0 (relevant if non-zero) pages!
2017-11-21T11:46:35.666932Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-11-21T11:46:36.267707Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-11-21T11:46:36.267729Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-11-21T11:46:36.267742Z 0 [ERROR] Failed to initialize plugins.
2017-11-21T11:46:36.267750Z 0 [ERROR] Aborting
 
2017-11-21T11:46:36.267768Z 0 [Note] Binlog end
2017-11-21T11:46:36.267919Z 0 [Note] Shutting down plugin 'CSV'
2017-11-21T11:46:36.268430Z 0 [Note] /app/mysql/bin/mysqld: Shutdown complete

删除:ibdata1、ib_logfile0、ib_logfile1 后启动正常

[root@yyfwq2 data]# rm -rf ibdata1 ib_logfile0 ib_logfile1
[root@yyfwq2 data]# service mysql start
Starting MySQL..............................................................................................................[  OK  ]

分析其原因:

数据在初始化是分配了ibdata1的大小。我在my.cnf中重新设置了innodb_data_file_path = ibdata1:1G:autoextend  导致启动时报错。

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • MySQL是怎么保证主备一致的

    MySQL是怎么保证主备一致的

    大家知道 binlog 可以用来归档,也可以用来做主备同步,但它的内容是什么样的呢?为什么备库执行了 binlog 就可以跟主库保持一致了呢,本文就详细的介绍一下
    2021-09-09
  • Linux系统下查看mysql版本的四种方法

    Linux系统下查看mysql版本的四种方法

    这篇文章主要介绍了Linux系统下查看mysql版本的四种方法,本文讲解了在终端下用mysql -V、使用mysql> status、在help里面查找 、使用mysql的函数等4种方法,需要的朋友可以参考下
    2015-05-05
  • MySQL 表的垂直拆分和水平拆分

    MySQL 表的垂直拆分和水平拆分

    这篇文章主要介绍了MySQL 表的垂直拆分和水平拆分,文中讲解非常细致,帮助大家更好的理解和学习MySQL,感兴趣的朋友可以了解下
    2020-07-07
  • MySQL性能优化配置参数之thread_cache和table_cache详解

    MySQL性能优化配置参数之thread_cache和table_cache详解

    这篇文章主要介绍了MySQL性能优化配置参数之thread_cache和table_cache详解,THREAD_CACHE是Mysql的连接池,table_cache指定表高速缓存的大小,需要的朋友可以参考下
    2014-07-07
  • MYSQL多表联查on和where的区别小结

    MYSQL多表联查on和where的区别小结

    在使用left join时过滤条件放到on后面还是where后面是有区别的,如果没有搞清楚他们的区别,连表汇总的结果就会变少或者变多,本文就来详细介绍一下两者的区别,感兴趣的可以了解一下
    2023-11-11
  • 解决MySQL报错1267 - Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPL问题

    解决MySQL报错1267 - Illegal mix of coll

    这篇文章主要给大家介绍了解决MySQL报错1267 - Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPL的问题,文中有详细的解决方案,需要的朋友可以参考下
    2023-09-09
  • mysql单字段多值分割和合并的处理方法

    mysql单字段多值分割和合并的处理方法

    这篇文章主要给大家介绍了关于mysql单字段多值分割和合并的处理方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-01-01
  • mysql 递归查找菜单节点的所有子节点的方法

    mysql 递归查找菜单节点的所有子节点的方法

    这篇文章主要介绍了mysql 递归查找菜单节点的所有子节点,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-11-11
  • 计算机管理服务中找不到mysql的服务的解决办法

    计算机管理服务中找不到mysql的服务的解决办法

    MySQL是一种流行的开源关系型数据库管理系统,用于存储和管理大量数据,在计算机管理中,启动MySQL服务是一项重要的任务,因为它可以确保数据库系统的顺利运行,这篇文章主要给大家介绍了关于计算机管理服务中找不到mysql的服务的解决办法,需要的朋友可以参考下
    2023-05-05
  • MySQL8.0内存相关参数总结

    MySQL8.0内存相关参数总结

    这篇文章主要介绍了MySQL8.0内存相关参数总结,帮助大家更好的理解和学习mysql,感兴趣的朋友可以了解下
    2020-08-08

最新评论