MariaDB: Shutdown right after start - mysql

So when i try to start mariadb this happens:
Job for mariadb.service failed because a timeout was exceeded.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
systemctl status mariadb.service shows this:
* mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Mon 2019-02-18 10:11:09 UTC; 4min 1s ago
Process: 779 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 692 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]
Process: 690 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 689 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 779 (code=exited, status=0/SUCCESS)
Feb 18 10:09:36 vps-zap348646-1 systemd[1]: Starting MariaDB database server...
Feb 18 10:09:37 vps-zap348646-1 mysqld[779]: 2019-02-18 10:09:37 140439143227328 [Note] /usr/sbin/mysqld (mysqld 10.1.29-MariaDB-6ubuntu2) starting as process
Feb 18 10:11:07 vps-zap348646-1 systemd[1]: mariadb.service: Start operation timed out. Terminating.
Feb 18 10:11:09 vps-zap348646-1 systemd[1]: mariadb.service: Failed with result 'timeout'.
Feb 18 10:11:09 vps-zap348646-1 systemd[1]: Failed to start MariaDB database server.
journalctl -xe shows this:
Feb 18 10:17:09 vps-zap348646-1 systemd[1]: Starting MariaDB database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mariadb.service has begun starting up.
Feb 18 10:17:10 vps-zap348646-1 mysqld[940]: 2019-02-18 10:17:10 139827003494336 [Note] /usr/sbin/mysqld (mysqld 10.1.29-MariaDB-6ubuntu2)
Feb 18 10:18:39 vps-zap348646-1 systemd[1]: mariadb.service: Start operation timed out. Terminating.
Feb 18 10:18:41 vps-zap348646-1 systemd[1]: mariadb.service: Failed with result 'timeout'.
Feb 18 10:18:41 vps-zap348646-1 systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mariadb.service has failed.
--
-- The result is RESULT.
And finally error.log in mysql:
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: The InnoDB memory heap is disabled
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Using Linux native AIO
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Using SSE crc32 instructions
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Initializing buffer pool, size = 1.0G
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Completed initialization of buffer pool
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Highest supported file format is Barracuda.
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: 128 rollback segment(s) are active.
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Waiting for purge to start
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.36-82.2 started; log sequence number 103241 029
2019-02-18 10:17:10 139827003494336 [Note] Plugin 'FEEDBACK' is disabled.
2019-02-18 10:17:10 139825235617536 [Note] InnoDB: Dumping buffer pool(s) not yet started
2019-02-18 10:17:10 139827003494336 [Note] Server socket created on IP: '127.0.0.1'.
2019-02-18 10:17:10 139827003494336 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.1.29-MariaDB-6ubuntu2' socket: '/var/run/mysqld/mysqld.sock' port: 3306 Ubuntu 18.10
2019-02-18 10:18:39 139827002763008 [Note] /usr/sbin/mysqld: Normal shutdown
2019-02-18 10:18:39 139827002763008 [Note] Event Scheduler: Purging the queue. 0 events
2019-02-18 10:18:39 139825283266304 [Note] InnoDB: FTS optimize thread exiting.
2019-02-18 10:18:39 139827002763008 [Note] InnoDB: Starting shutdown...
2019-02-18 10:18:39 139827002763008 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2019-02-18 10:18:41 139827002763008 [Note] InnoDB: Shutdown completed; log sequence number 103241039
2019-02-18 10:18:41 139827002763008 [Note] /usr/sbin/mysqld: Shutdown complete
Either I am blind or there just isn't any error and mariadb is just not working.
Maybe one of you guys have an idea. Thanks.
Edit:
I found a "solution" for now, mariadb is shutting down because of a timeout when starting, so for now I set the timeout to 0. For now this solution is enough but there must be a real solution.

Please note that since 10.1.10, MariaDB uses systemd to start the service. The /etc/init.d/mysql script is no longer used, so MYSQLD_STARTUP_TIMEOUT has no effect.
You need to find your mariadb.service file. In our case, it did not contain a timeout so the MariaDB default was being used. Just add /etc/systemd/system/mariadb.service.d/override.conf file, and put in it:
[Service]
TimeoutStartSec = 0
In the [Service] section, and it will never time out. After create the file:
# systemctl daemon-reload
# systemctl restart mysql.service

Related

How to fix MariaDB InnoDB "Data structure corruption" after using plesk system reboot

I logged into the server using SSH and it said my server needed to have a reboot. So I logged into my plesk panel and hit the restart server button. After the reboot... MySQL/MariaDB doesn't start anymore. I'm getting errors that seem to indicate database corruption. I would really appreciate some advice on how to fix this issue. I don't encounter this problem very often.
Some sites have said to reinstall the database. Other places have said to use innodb_force_recovery. I do not have any backups (I know, Shame on me. This is a personal server.). I DO have a copy of the /var/lib/mysql directory. Though the copy is taken AFTER the database stopped booting.
OS: Ubuntu 20.04LTS
"journal -xe" outputs this info:
[Note] InnoDB: Using Linux native AIO
[Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
[Note] InnoDB: Uses event mutexes
[Note] InnoDB: Compressed tables use zlib 1.2.11
[Note] InnoDB: Number of pools: 1
[Note] InnoDB: Using SSE2 crc32 instructions
[Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
[Note] InnoDB: Completed initialization of buffer pool
[Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man pa>
[ERROR] InnoDB: Invalid flags 0x4000 in ./ibdata1
[ERROR] InnoDB: Plugin initialization aborted with error Data structure corruption
[Note] InnoDB: Starting shutdown...
Apr 16 12:45:41 mysite.com named[1988]: client #0x7feec0011480 1.2.3.4#68 (sl): query (cache) 'sl/ANY/IN' denied
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[Note] Plugin 'FEEDBACK' is disabled.
[ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
Apr 16 12:45:41 mysite.com systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit mariadb.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Apr 16 12:45:41 mysite.com systemd[1]: mariadb.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mariadb.service has entered the 'failed' state with result 'exit-code'.
Apr 16 12:45:41 mysite.com systemd[1]: Failed to start MariaDB 10.3.34 database server.
-- Subject: A start job for unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mariadb.service has finished with a failure.
--
-- The job identifier is 9726 and the job result is failed.

Changing tmpdir in my.cnf causes mysql to fail to restart

I'm trying to change where mysql uses for temporary tables. I have a drive mounted at /media/E, and I've created a directory owned by root with permissions drwxrwxrwxt at /media/E/tmp.
I have changed tmpdir in /etc/mysql/mysql.conf.d/mysqld.cnf to point to this directory.
I then restart mysql like so:
username#grey:/media/E/tmp$ sudo service mysql restart
Yielding the following error:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Here is the result of systemctl status mysql.service:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2021-08-05 16:56:07 BST; 3min 11s ago
Process: 28964 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 28938 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 24216 (code=exited, status=0/SUCCESS)
Aug 05 16:56:07 computer systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Aug 05 16:56:07 computer systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Aug 05 16:56:07 computer systemd[1]: Stopped MySQL Community Server.
Aug 05 16:56:07 computer systemd[1]: mysql.service: Start request repeated too quickly.
Aug 05 16:56:07 computer systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 05 16:56:07 computer systemd[1]: Failed to start MySQL Community Server.
mysql error.log:
2021-08-05T15:56:05.385461Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-05T15:56:05.387065Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.35-0ubuntu0.18.04.1) starting as process 28785 ...
2021-08-05T15:56:05.391963Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-08-05T15:56:05.391993Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-08-05T15:56:05.391999Z 0 [Note] InnoDB: Uses event mutexes
2021-08-05T15:56:05.392004Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-08-05T15:56:05.392009Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-08-05T15:56:05.392014Z 0 [Note] InnoDB: Using Linux native AIO
2021-08-05T15:56:05.392223Z 0 [Note] InnoDB: Number of pools: 1
2021-08-05T15:56:05.392308Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqld: Can't create/write to file '/media/E/tmp/ib0OZZH0' (Errcode: 13 - Permission denied)
2021-08-05T15:56:05.392355Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2021-08-05T15:56:05.392362Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2021-08-05T15:56:05.392368Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-08-05T15:56:05.392372Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-08-05T15:56:05.392376Z 0 [ERROR] Failed to initialize builtin plugins.
2021-08-05T15:56:05.392380Z 0 [ERROR] Aborting
2021-08-05T15:56:05.392398Z 0 [Note] Binlog end
2021-08-05T15:56:05.392455Z 0 [Note] Shutting down plugin 'CSV'
2021-08-05T15:56:05.392742Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2021-08-05T15:56:05.922766Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-05T15:56:05.924030Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.35-0ubuntu0.18.04.1) starting as process 28830 ...
2021-08-05T15:56:05.927684Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-08-05T15:56:05.927705Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-08-05T15:56:05.927711Z 0 [Note] InnoDB: Uses event mutexes
2021-08-05T15:56:05.927716Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-08-05T15:56:05.927720Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-08-05T15:56:05.927725Z 0 [Note] InnoDB: Using Linux native AIO
2021-08-05T15:56:05.927922Z 0 [Note] InnoDB: Number of pools: 1
2021-08-05T15:56:05.928009Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqld: Can't create/write to file '/media/E/tmp/ibTpGlkH' (Errcode: 13 - Permission denied)
2021-08-05T15:56:05.928121Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2021-08-05T15:56:05.928128Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2021-08-05T15:56:05.928133Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-08-05T15:56:05.928136Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-08-05T15:56:05.928140Z 0 [ERROR] Failed to initialize builtin plugins.
2021-08-05T15:56:05.928143Z 0 [ERROR] Aborting
2021-08-05T15:56:05.928160Z 0 [Note] Binlog end
2021-08-05T15:56:05.928199Z 0 [Note] Shutting down plugin 'CSV'
2021-08-05T15:56:05.928422Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2021-08-05T15:56:06.432240Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-05T15:56:06.433500Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.35-0ubuntu0.18.04.1) starting as process 28876 ...
2021-08-05T15:56:06.437655Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-08-05T15:56:06.437707Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-08-05T15:56:06.437716Z 0 [Note] InnoDB: Uses event mutexes
2021-08-05T15:56:06.437724Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-08-05T15:56:06.437732Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-08-05T15:56:06.437740Z 0 [Note] InnoDB: Using Linux native AIO
2021-08-05T15:56:06.438087Z 0 [Note] InnoDB: Number of pools: 1
2021-08-05T15:56:06.438218Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqld: Can't create/write to file '/media/E/tmp/ibuYEQaa' (Errcode: 13 - Permission denied)
2021-08-05T15:56:06.438274Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2021-08-05T15:56:06.438285Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2021-08-05T15:56:06.438293Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-08-05T15:56:06.438299Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-08-05T15:56:06.438306Z 0 [ERROR] Failed to initialize builtin plugins.
2021-08-05T15:56:06.438311Z 0 [ERROR] Aborting
2021-08-05T15:56:06.438338Z 0 [Note] Binlog end
2021-08-05T15:56:06.438394Z 0 [Note] Shutting down plugin 'CSV'
2021-08-05T15:56:06.438799Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2021-08-05T15:56:06.933005Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-05T15:56:06.934428Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.35-0ubuntu0.18.04.1) starting as process 28919 ...
2021-08-05T15:56:06.938763Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-08-05T15:56:06.938803Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-08-05T15:56:06.938812Z 0 [Note] InnoDB: Uses event mutexes
2021-08-05T15:56:06.938820Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-08-05T15:56:06.938828Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-08-05T15:56:06.938836Z 0 [Note] InnoDB: Using Linux native AIO
2021-08-05T15:56:06.939095Z 0 [Note] InnoDB: Number of pools: 1
2021-08-05T15:56:06.939192Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqld: Can't create/write to file '/media/E/tmp/ibrNdqJK' (Errcode: 13 - Permission denied)
2021-08-05T15:56:06.939294Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2021-08-05T15:56:06.939305Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2021-08-05T15:56:06.939311Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-08-05T15:56:06.939317Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-08-05T15:56:06.939323Z 0 [ERROR] Failed to initialize builtin plugins.
2021-08-05T15:56:06.939328Z 0 [ERROR] Aborting
2021-08-05T15:56:06.939373Z 0 [Note] Binlog end
2021-08-05T15:56:06.939481Z 0 [Note] Shutting down plugin 'CSV'
2021-08-05T15:56:06.939965Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2021-08-05T15:56:07.433078Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-05T15:56:07.434360Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.35-0ubuntu0.18.04.1) starting as process 28966 ...
2021-08-05T15:56:07.438280Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-08-05T15:56:07.438321Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-08-05T15:56:07.438326Z 0 [Note] InnoDB: Uses event mutexes
2021-08-05T15:56:07.438331Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-08-05T15:56:07.438335Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-08-05T15:56:07.438340Z 0 [Note] InnoDB: Using Linux native AIO
2021-08-05T15:56:07.438590Z 0 [Note] InnoDB: Number of pools: 1
2021-08-05T15:56:07.438678Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqld: Can't create/write to file '/media/E/tmp/ibr3ovUd' (Errcode: 13 - Permission denied)
2021-08-05T15:56:07.438726Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2021-08-05T15:56:07.438733Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2021-08-05T15:56:07.438738Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-08-05T15:56:07.438742Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-08-05T15:56:07.438747Z 0 [ERROR] Failed to initialize builtin plugins.
2021-08-05T15:56:07.438750Z 0 [ERROR] Aborting
2021-08-05T15:56:07.438773Z 0 [Note] Binlog end
2021-08-05T15:56:07.438824Z 0 [Note] Shutting down plugin 'CSV'
2021-08-05T15:56:07.439214Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
MySQL is armored by AppArmor, which does not allow writing freely to /media/E/tmp. To remedy the situation, you can edit the /etc/apparmor.d/abstractions/user-tmp and add the /media/E/tmp there appropriately; for me the extra lines
owner /media/E/tmp/** rwkl,
/media/E/tmp/ rw,

why Change the status of Mysql to Failed every few hours

Mysql status fails every few hours, I also checked the buffer size, no problem with them and
The following message is displayed with the below command:
systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Wed 2020-12-02 17:05:42 EST; 8h ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 25565 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 25543 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 17582 (code=killed, signal=KILL)
Dec 02 17:05:42 test.local systemd[1]: Failed to start MySQL Server.
Dec 02 17:05:42 test.local systemd[1]: Unit mysqld.service entered failed state.
Dec 02 17:05:42 test.local systemd[1]: mysqld.service failed.
Dec 02 17:05:42 test.local systemd[1]: mysqld.service holdoff time over, scheduling restart.
Dec 02 17:05:42 test.local systemd[1]: Stopped MySQL Server.
Dec 02 17:05:42 test.local systemd[1]: start request repeated too quickly for mysqld.service
Dec 02 17:05:42 test.local systemd[1]: Failed to start MySQL Server.
Dec 02 17:05:42 test.local systemd[1]: Unit mysqld.service entered failed state.
Dec 02 17:05:42 test.local systemd[1]: mysqld.service failed.
I also checked the log file and the following event occurred:
2020-12-02T22:05:42.179677Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation $2020-12-02T22:05:42.184072Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31) starting as process 25570 ...
2020-12-02T22:05:42.204497Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-12-02T22:05:42.204557Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-12-02T22:05:42.204565Z 0 [Note] InnoDB: Uses event mutexes
2020-12-02T22:05:42.204574Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-12-02T22:05:42.204579Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-12-02T22:05:42.204584Z 0 [Note] InnoDB: Using Linux native AIO
2020-12-02T22:05:42.204998Z 0 [Note] InnoDB: Number of pools: 1
2020-12-02T22:05:42.205184Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-12-02T22:05:42.208098Z 0 [Note] InnoDB: Initializing buffer pool, total size = 6G, instances = 8, chunk size = 128M
2020-12-02T22:05:42.443914Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-12-02T22:05:42.510301Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-12-02T22:05:42.510359Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-12-02T22:05:42.510376Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-12-02T22:05:42.510384Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-12-02T22:05:42.510391Z 0 [ERROR] Failed to initialize builtin plugins.
2020-12-02T22:05:42.510399Z 0 [ERROR] Aborting
2020-12-02T22:05:42.510438Z 0 [Note] Binlog end
2020-12-02T22:05:42.510525Z 0 [Note] Shutting down plugin 'CSV'
2020-12-02T22:05:42.511922Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
also My.cf file:
[mysqld]
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
symbolic-links=0
innodb_file_per_table = 1
myisam_sort_buffer_size = 64M
read_rnd_buffer_size = 1024K
net_buffer_length = 8K
read_buffer_size = 1024K
sort_buffer_size = 1024K
table_open_cache = 64
max_allowed_packet = 2M
key_buffer_size = 64M
innodb_buffer_pool_size = 6024M
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
I tested this project on a server with 2 GB of RAM, but it failed on a server with 8 GB of RAM.
Consider these changes to your my.cnf [mysqld] section
innodb_buffer_pool_size=4G
and REMOVE to allow defaults to work for improved performance
read_rnd_buffer_size
read_buffer_size
sort_buffer_size
to reduce RAM footprint.
For additional suggestions, view my profile, Network profile for contact info and free downloadable Utility Scripts to assist with performance tuning.

Cannot restart mysql after restarting servers

MySql was operating normally and system had some problems,but start mysql with error after restarting servers.System version:CentOS Linux release 7.7.1908
How to resolve this?
this is log
[flink#master sbin]$ ./mysqld
2020-07-22 15:42:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-07-22 15:42:13 0 [Note] ./mysqld (mysqld 5.6.45) starting as process 6401 ...
2020-07-22 15:42:13 6401 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5010)
2020-07-22 15:42:13 6401 [Warning] Buffered warning: Changed limits: max_connections: 214 (requested 1000)
2020-07-22 15:42:13 6401 [Warning] Buffered warning: Changed limits: table_open_cache: 400 (requested 2000)
2020-07-22 15:42:13 6401 [Note] Plugin 'FEDERATED' is disabled.
./mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2020-07-22 15:42:13 6401 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2020-07-22 15:42:13 6401 [Note] InnoDB: Using atomics to ref count buffer pool pages
2020-07-22 15:42:13 6401 [Note] InnoDB: The InnoDB memory heap is disabled
2020-07-22 15:42:13 6401 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-07-22 15:42:13 6401 [Note] InnoDB: Memory barrier is not used
2020-07-22 15:42:13 6401 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-22 15:42:13 6401 [Note] InnoDB: Using Linux native AIO
2020-07-22 15:42:13 6401 [Note] InnoDB: Using CPU crc32 instructions
2020-07-22 15:42:13 6401 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2020-07-22 15:42:13 6401 [Note] InnoDB: Completed initialization of buffer pool
2020-07-22 15:42:13 6401 [Note] InnoDB: Highest supported file format is Barracuda.
2020-07-22 15:42:13 6401 [Note] InnoDB: 128 rollback segment(s) are active.
2020-07-22 15:42:13 6401 [Note] InnoDB: Waiting for purge to start
2020-07-22 15:42:13 6401 [Note] InnoDB: 5.6.45 started; log sequence number 1600627
2020-07-22 15:42:13 6401 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: db5e3d0e-cbee-11ea-9
this is sql status after starting mysql
[flink#master mysql]$ systemctl status mysqld
● mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (start-post) (Result: exit-code) since Wed 2020-07-22 15:49:34 CST; 1min 5s ago
Process: 8318 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=1/FAILURE)
Process: 8303 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 8318 (code=exited, status=1/FAILURE); : 8319 (mysql-systemd-s)
Tasks: 2
Memory: 17.7M
CGroup: /system.slice/mysqld.service
└─control
├─8319 /bin/bash /usr/bin/mysql-systemd-start post
└─8817 sleep 1
Jul 22 15:49:34 master systemd[1]: Starting MySQL Community Server...
Jul 22 15:49:35 master mysqld_safe[8318]: 200722 15:49:35 mysqld_safe Logging to '/var/lib/mysql/mysqld.log'.
Jul 22 15:49:35 master mysqld_safe[8318]: /usr/bin/mysqld_safe: line 138: /var/lib/mysql/mysqld.log: Permission denied
Jul 22 15:49:35 master mysqld_safe[8318]: 200722 15:49:35 mysqld_safe Directory '/home/flink/hdd/mysql_data/mysql' for UNIX socket file... exists.
Jul 22 15:49:35 master systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Hint: Some lines were ellipsized, use -l to show in full.

MySql service won´t start [ubuntu]

Today at around 6:23 UTC my Ubuntu Server 16.04 in Amazon EC2 made an automated apt update. From around this time my MySql server refuses to start.
At first he told me the apparmor config was wrong (like here: mysql wont start Ubuntu 16.04.2 x64) which i fixed.
Now when I try to start the mysql service like this:
:~$ sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service
failed because the control process exited with error code. See "systemctl
status mysql.service" and "journalctl -xe" for details.
failed!
systemctl status mysql.service :
:~$ sudo systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Tue 2018-04-24 19:01:31 UTC; 27s ago
Process: 22818 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 22809 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 22818 (code=exited, status=1/FAILURE); : 22819 (mysql-systemd-s)
Tasks: 2
Memory: 324.0K
CPU: 287ms
CGroup: /system.slice/mysql.service
└─control
├─22819 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─22903 sleep 1
Apr 24 19:01:31 ip-172-31-38-155 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 24 19:01:31 ip-172-31-38-155 systemd[1]: Stopped MySQL Community Server.
Apr 24 19:01:31 ip-172-31-38-155 systemd[1]: Starting MySQL Community Server...
Apr 24 19:01:33 ip-172-31-38-155 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
and the journalctl -ex looks like this:
journalctl -xe
-- The result is failed.
Apr 24 19:05:41 ip-172-31-38-155 systemd[1]: mysql.service: Unit entered failed state.
Apr 24 19:05:41 ip-172-31-38-155 systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 24 19:05:41 ip-172-31-38-155 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 24 19:05:41 ip-172-31-38-155 systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Apr 24 19:05:41 ip-172-31-38-155 systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Apr 24 19:05:43 ip-172-31-38-155 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Apr 24 19:06:12 ip-172-31-38-155 systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Apr 24 19:06:12 ip-172-31-38-155 systemd[1]: mysql.service: Unit entered failed state.
Apr 24 19:06:12 ip-172-31-38-155 systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 24 19:06:12 ip-172-31-38-155 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 24 19:06:12 ip-172-31-38-155 systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Apr 24 19:06:12 ip-172-31-38-155 systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Apr 24 19:06:14 ip-172-31-38-155 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
While the the cat /var/log/mysql/error.log | grep ERROR prints loads of these errors:
2018-04-24T19:10:22.941983Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-04-24T19:10:22.942643Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2018-04-24T19:10:22.942683Z 0 [ERROR] Aborting
The one whole cycle of the cat /var/log/error.log would look like this:
2018-04-24T19:14:01.701232Z 0 [Note] Shutting down plugin 'ngram'
2018-04-24T19:14:01.701238Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2018-04-24T19:14:01.701241Z 0 [Note] Shutting down plugin 'partition'
2018-04-24T19:14:01.701243Z 0 [Note] Shutting down plugin 'ARCHIVE'
2018-04-24T19:14:01.701246Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2018-04-24T19:14:01.701249Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2018-04-24T19:14:01.701251Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2018-04-24T19:14:01.701253Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2018-04-24T19:14:01.701256Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2018-04-24T19:14:01.701258Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2018-04-24T19:14:01.701260Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2018-04-24T19:14:01.701263Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2018-04-24T19:14:01.701265Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2018-04-24T19:14:01.701267Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2018-04-24T19:14:01.701270Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2018-04-24T19:14:01.701272Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2018-04-24T19:14:01.701274Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2018-04-24T19:14:01.701277Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2018-04-24T19:14:01.701279Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2018-04-24T19:14:01.701282Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2018-04-24T19:14:01.701284Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2018-04-24T19:14:01.701286Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2018-04-24T19:14:01.701289Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2018-04-24T19:14:01.701291Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2018-04-24T19:14:01.701293Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2018-04-24T19:14:01.701296Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2018-04-24T19:14:01.701298Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2018-04-24T19:14:01.701300Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2018-04-24T19:14:01.701303Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2018-04-24T19:14:01.701305Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2018-04-24T19:14:01.701307Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2018-04-24T19:14:01.701310Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2018-04-24T19:14:01.701312Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2018-04-24T19:14:01.701314Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2018-04-24T19:14:01.701317Z 0 [Note] Shutting down plugin 'InnoDB'
2018-04-24T19:14:01.701363Z 0 [Note] InnoDB: FTS optimize thread exiting.
2018-04-24T19:14:01.701444Z 0 [Note] InnoDB: Starting shutdown...
2018-04-24T19:14:01.701486Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-04-24T19:14:01.701522Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180424 19:14:01 (/var/lib/mysql/ib_buffer_pool was empty)
2018-04-24T19:14:01.701533Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2018-04-24T19:14:01.701632Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 180424 19:14:01
2018-04-24T19:14:03.309269Z 0 [Note] InnoDB: Shutdown completed; log sequence number 8715994
2018-04-24T19:14:03.310751Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-04-24T19:14:03.310767Z 0 [Note] Shutting down plugin 'MyISAM'
2018-04-24T19:14:03.310781Z 0 [Note] Shutting down plugin 'CSV'
2018-04-24T19:14:03.310794Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2018-04-24T19:14:03.310840Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2018-04-24T19:14:03.310844Z 0 [Note] Shutting down plugin 'MEMORY'
2018-04-24T19:14:03.310848Z 0 [Note] Shutting down plugin 'sha256_password'
2018-04-24T19:14:03.310850Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-04-24T19:14:03.310975Z 0 [Note] Shutting down plugin 'binlog'
2018-04-24T19:14:03.311078Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2018-04-24T19:14:32.669339Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-04-24T19:14:32.669378Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2018-04-24T19:14:32.820589Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-24T19:14:32.822172Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.22-0ubuntu0.16.04.1) starting as process 25440 ...
2018-04-24T19:14:32.826095Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-04-24T19:14:32.826121Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-04-24T19:14:32.826125Z 0 [Note] InnoDB: Uses event mutexes
2018-04-24T19:14:32.826129Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-04-24T19:14:32.826133Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-04-24T19:14:32.826136Z 0 [Note] InnoDB: Using Linux native AIO
2018-04-24T19:14:32.826367Z 0 [Note] InnoDB: Number of pools: 1
2018-04-24T19:14:32.826496Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-04-24T19:14:32.827971Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-04-24T19:14:32.835607Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-04-24T19:14:32.837529Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-04-24T19:14:32.849179Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-04-24T19:14:32.858128Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-04-24T19:14:32.858180Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-04-24T19:14:32.892813Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-04-24T19:14:32.893685Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-04-24T19:14:32.893696Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-04-24T19:14:32.893952Z 0 [Note] InnoDB: Waiting for purge to start
2018-04-24T19:14:32.944316Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 8715994
2018-04-24T19:14:32.944678Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2018-04-24T19:14:32.944791Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-04-24T19:14:32.945139Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-04-24T19:14:32.945192Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-04-24T19:14:32.945201Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-04-24T19:14:32.945209Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2018-04-24T19:14:32.945237Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-04-24T19:14:32.945363Z 0 [Warning] Failed to open optimizer cost constant tables
2018-04-24T19:14:32.945455Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2018-04-24T19:14:32.945497Z 0 [ERROR] Aborting
2018-04-24T19:14:32.945522Z 0 [Note] Binlog end
On the one hand I have seen that the the error.log tells me to run run mysql_upgrade which i cannot do because the database itself is not running.
The [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist should be fixed by an initilize command onto the service which wont work either because the service itself is not running.
I do not have a single clue what to do next. My personal best Idea for now would be to reinstall the MySql server and copy beforehand the /var/lib/mysql/mysql and the /etc/mysql directories to insert them later as a backup.
I hope anyone of you has heard something about the problem or has any kind of idea what to do. Preferably while keeping my Data.
I hope, I provided all information you need. If you need any more, just ask.
Thanks a lot in advance!