启动 mysql 失败,因为控制进程退出,错误代码为

启动 mysql 失败,因为控制进程退出,错误代码为

好的。首先,我尝试在服务器上运行一个网站,但它对于 MySQL 来说太重了。显然,它由于缺乏 RAM 而崩溃了。因此,我更改了服务器的 .cnf 和 .ini 文件以降低负载,尽管我知道这样运行起来会慢得多。

现在我尝试重新启动服务器。

$ sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control p
rocess exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

 failed!

由于某种原因,它失败了。我完全不知道哪里出了问题。这是 MySQL 日志,我还需要修复什么?

2019-01-31T02:10:13.714141Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-31T02:10:13.716372Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.25-0ubuntu0.18.10.2) starting as process 24740 ...
2019-01-31T02:10:13.720956Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-01-31T02:10:13.720991Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-01-31T02:10:13.720995Z 0 [Note] InnoDB: Uses event mutexes
2019-01-31T02:10:13.720999Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-01-31T02:10:13.721002Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-01-31T02:10:13.721005Z 0 [Note] InnoDB: Using Linux native AIO
2019-01-31T02:10:13.721292Z 0 [Note] InnoDB: Number of pools: 1
2019-01-31T02:10:13.721420Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-01-31T02:10:13.725482Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-01-31T02:10:13.725537Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2019-01-31T02:10:13.725544Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2019-01-31T02:10:13.725548Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-01-31T02:10:13.725558Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-01-31T02:10:13.725563Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-01-31T02:10:13.725568Z 0 [ERROR] Failed to initialize builtin plugins.
2019-01-31T02:10:13.725571Z 0 [ERROR] Aborting
2019-01-31T02:10:13.728065Z 0 [Note] Binlog end
2019-01-31T02:10:13.728148Z 0 [Note] Shutting down plugin 'CSV'
2019-01-31T02:10:13.728458Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

/etc/mysql/mysql.conf.d/mysqld.cnf 文件:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0
[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
sort_buffer_size        = 16M
read_buffer_size        = 1M
write_buffer_size       = 1M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP
max_connections         = 5
table_open_cache        = 32
thread_concurrency      = 6
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M
#
#thanks https://forums.cpanel.net/threads/optimizing-mysql-for-512mb-80-of-installed-ram.170278/
#
table_cache = 256
myisam_sort_buffer_size = 16M
thread_cache_size = 8
wait_timeout = 60
connect_timeout = 30
interactive-timeout = 50
query-cache-type = 1
query_cache_size = 8M
query_cache_limit = 1M
max_user_connections = 5
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#slow_query_log         = 1
#slow_query_log_file    = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size   = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#

我感觉我把一切都破坏了……

答案1

您的 RAM 非常小。找到 MySQL 的 my.cnf 配置文件,然后将其调低innodb_buffer_pool_size至大约 20M。如果您仍然收到错误 12,请向我们显示该文件,我们可以建议减少其他一些内容。

相关内容