I have a virtual root server with a freshly installed version of ubuntu-18.04-x86_64
. I’m using root
user access, if that matters.
First, I ran sudo apt update
, then sudo apt upgrade
, then I rebooted the server.
Then, I wanted to install a MySQL server with the following command: sudo apt install mysql-server
Here’s a snippet of the console output:
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Initialization of mysqld failed: 0
Warning: Unable to start the server.
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Tue 2020-10-20 07:29:31 UTC; 7ms ago
Process: 1086 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 1077 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Oct 20 07:29:31 myserver.example.com systemd[1]: mysql.service: Failed with result 'exit-code'.
Oct 20 07:29:31 myserver.example.com systemd[1]: Failed to start MySQL Community Server.
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for systemd (237-3ubuntu10.42) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
I rebooted the server and then tried to start MySQL like this: sudo systemctl start mysql
This gave me:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service
results to:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-10-20 07:33:09 UTC; 1min 27s ago
Process: 763 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 754 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Oct 20 07:33:09 myserver.example.com systemd[1]: Failed to start MySQL Community Server.
Oct 20 07:33:09 myserver.example.com systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Oct 20 07:33:09 myserver.example.com systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Oct 20 07:33:09 myserver.example.com systemd[1]: Stopped MySQL Community Server.
Oct 20 07:33:09 myserver.example.com systemd[1]: mysql.service: Start request repeated too quickly.
Oct 20 07:33:09 myserver.example.com systemd[1]: mysql.service: Failed with result 'exit-code'.
Oct 20 07:33:09 myserver.example.com systemd[1]: Failed to start MySQL Community Server.
journalctl -xe
shows the following:
-- The user manager instance for user 0 has been started. All services queued
-- for starting have been started. Note that other services might still be starting
-- up or be started at any later time.
--
-- Startup of the manager took 90154601 microseconds.
Oct 20 07:33:53 myserver.example.com sshd[769]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:33:55 myserver.example.com sshd[769]: Failed password for root from 106.12.205.55 port 44532 ssh2
Oct 20 07:33:56 myserver.example.com sshd[769]: Received disconnect from 106.12.205.55 port 44532:11: Bye Bye [pre
Oct 20 07:33:56 myserver.example.com sshd[769]: Disconnected from authenticating user root 106.12.205.55 port 4453
Oct 20 07:33:58 myserver.example.com sshd[771]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:34:00 myserver.example.com sshd[771]: Failed password for root from 99.96.122.99 port 45514 ssh2
Oct 20 07:34:00 myserver.example.com sshd[771]: Received disconnect from 99.96.122.99 port 45514:11: Bye Bye [prea
Oct 20 07:34:00 myserver.example.com sshd[771]: Disconnected from authenticating user root 99.96.122.99 port 45514
Oct 20 07:34:30 myserver.example.com sshd[773]: Invalid user backuppc from 45.248.71.169 port 55626
Oct 20 07:34:30 myserver.example.com sshd[773]: pam_unix(sshd:auth): check pass; user unknown
Oct 20 07:34:30 myserver.example.com sshd[773]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:34:33 myserver.example.com sshd[773]: Failed password for invalid user backuppc from 45.248.71.169 port
Oct 20 07:34:33 myserver.example.com sshd[773]: Received disconnect from 45.248.71.169 port 55626:11: Bye Bye [pre
Oct 20 07:34:33 myserver.example.com sshd[773]: Disconnected from invalid user backuppc 45.248.71.169 port 55626 [
Oct 20 07:34:41 myserver.example.com sshd[779]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:34:42 myserver.example.com sshd[778]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:34:42 myserver.example.com sshd[779]: Failed password for root from 27.156.4.11 port 42758 ssh2
Oct 20 07:34:43 myserver.example.com sshd[779]: Received disconnect from 27.156.4.11 port 42758:11: Bye Bye [preau
Oct 20 07:34:43 myserver.example.com sshd[779]: Disconnected from authenticating user root 27.156.4.11 port 42758
Oct 20 07:34:44 myserver.example.com sshd[778]: Failed password for root from 42.200.80.42 port 45326 ssh2
Oct 20 07:34:45 myserver.example.com sshd[778]: Received disconnect from 42.200.80.42 port 45326:11: Bye Bye [prea
Oct 20 07:34:45 myserver.example.com sshd[778]: Disconnected from authenticating user root 42.200.80.42 port 45326
Oct 20 07:34:45 myserver.example.com sshd[782]: Invalid user rancher from 211.108.69.103 port 55852
Oct 20 07:34:45 myserver.example.com sshd[782]: pam_unix(sshd:auth): check pass; user unknown
Oct 20 07:34:45 myserver.example.com sshd[782]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:34:47 myserver.example.com sshd[782]: Failed password for invalid user rancher from 211.108.69.103 port
Oct 20 07:34:47 myserver.example.com sshd[782]: Received disconnect from 211.108.69.103 port 55852:11: Bye Bye [pr
Oct 20 07:34:47 myserver.example.com sshd[782]: Disconnected from invalid user rancher 211.108.69.103 port 55852 [
Oct 20 07:34:58 myserver.example.com sshd[784]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:34:59 myserver.example.com sshd[784]: Failed password for root from 111.229.160.86 port 44378 ssh2
Oct 20 07:35:00 myserver.example.com sshd[784]: Received disconnect from 111.229.160.86 port 44378:11: Bye Bye [pr
Oct 20 07:35:00 myserver.example.com sshd[784]: Disconnected from authenticating user root 111.229.160.86 port 443
Oct 20 07:35:15 myserver.example.com sshd[786]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0
Oct 20 07:35:17 myserver.example.com sshd[786]: Failed password for mysql from 103.39.236.214 port 51680 ssh2
Oct 20 07:35:18 myserver.example.com sshd[786]: Received disconnect from 103.39.236.214 port 51680:11: Bye Bye [pr
Oct 20 07:35:18 myserver.example.com sshd[786]: Disconnected from authenticating user mysql 103.39.236.214 port 51
lines 3564-3604/3604 (END)
Also, I rebooted the system, cleared the file /var/log/mysql/error.log
and executed the following: sudo systemctl start mysql
/var/log/mysql/error.log
now contains:
2020-10-20T08:35:10.872789Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-10-20T08:35:10.874226Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 706 ...
2020-10-20T08:35:10.878084Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-10-20T08:35:10.878118Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-10-20T08:35:10.878123Z 0 [Note] InnoDB: Uses event mutexes
2020-10-20T08:35:10.878128Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-10-20T08:35:10.878132Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-10-20T08:35:10.878138Z 0 [Note] InnoDB: Using Linux native AIO
2020-10-20T08:35:10.878362Z 0 [Note] InnoDB: Number of pools: 1
2020-10-20T08:35:10.878481Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-10-20T08:35:10.879843Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-10-20T08:35:10.879879Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-10-20T08:35:10.879887Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-10-20T08:35:10.879894Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-10-20T08:35:10.879900Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-10-20T08:35:10.879904Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-10-20T08:35:10.879909Z 0 [ERROR] Failed to initialize builtin plugins.
2020-10-20T08:35:10.879912Z 0 [ERROR] Aborting
2020-10-20T08:35:10.879932Z 0 [Note] Binlog end
2020-10-20T08:35:10.879977Z 0 [Note] Shutting down plugin 'CSV'
2020-10-20T08:35:10.880288Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2020-10-20T08:35:11.552813Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-10-20T08:35:11.554246Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 719 ...
2020-10-20T08:35:11.558181Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-10-20T08:35:11.558218Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-10-20T08:35:11.558224Z 0 [Note] InnoDB: Uses event mutexes
2020-10-20T08:35:11.558229Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-10-20T08:35:11.558233Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-10-20T08:35:11.558239Z 0 [Note] InnoDB: Using Linux native AIO
2020-10-20T08:35:11.558466Z 0 [Note] InnoDB: Number of pools: 1
2020-10-20T08:35:11.558573Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-10-20T08:35:11.559862Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-10-20T08:35:11.559897Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-10-20T08:35:11.559908Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-10-20T08:35:11.559915Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-10-20T08:35:11.559922Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-10-20T08:35:11.559926Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-10-20T08:35:11.559932Z 0 [ERROR] Failed to initialize builtin plugins.
2020-10-20T08:35:11.559937Z 0 [ERROR] Aborting
2020-10-20T08:35:11.559963Z 0 [Note] Binlog end
2020-10-20T08:35:11.560023Z 0 [Note] Shutting down plugin 'CSV'
2020-10-20T08:35:11.560415Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2020-10-20T08:35:12.244404Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-10-20T08:35:12.245881Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 732 ...
2020-10-20T08:35:12.249734Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-10-20T08:35:12.249768Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-10-20T08:35:12.249773Z 0 [Note] InnoDB: Uses event mutexes
2020-10-20T08:35:12.249786Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-10-20T08:35:12.249791Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-10-20T08:35:12.249798Z 0 [Note] InnoDB: Using Linux native AIO
2020-10-20T08:35:12.250033Z 0 [Note] InnoDB: Number of pools: 1
2020-10-20T08:35:12.250132Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-10-20T08:35:12.251436Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-10-20T08:35:12.251481Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-10-20T08:35:12.251492Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-10-20T08:35:12.251500Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-10-20T08:35:12.251507Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-10-20T08:35:12.251511Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-10-20T08:35:12.251517Z 0 [ERROR] Failed to initialize builtin plugins.
2020-10-20T08:35:12.251520Z 0 [ERROR] Aborting
2020-10-20T08:35:12.251539Z 0 [Note] Binlog end
2020-10-20T08:35:12.251586Z 0 [Note] Shutting down plugin 'CSV'
2020-10-20T08:35:12.251937Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2020-10-20T08:35:12.731410Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-10-20T08:35:12.733442Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 745 ...
2020-10-20T08:35:12.739038Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-10-20T08:35:12.739088Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-10-20T08:35:12.739100Z 0 [Note] InnoDB: Uses event mutexes
2020-10-20T08:35:12.739108Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-10-20T08:35:12.739114Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-10-20T08:35:12.739124Z 0 [Note] InnoDB: Using Linux native AIO
2020-10-20T08:35:12.739462Z 0 [Note] InnoDB: Number of pools: 1
2020-10-20T08:35:12.739603Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-10-20T08:35:12.741440Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-10-20T08:35:12.741504Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-10-20T08:35:12.741523Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-10-20T08:35:12.741537Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-10-20T08:35:12.741548Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-10-20T08:35:12.741554Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-10-20T08:35:12.741562Z 0 [ERROR] Failed to initialize builtin plugins.
2020-10-20T08:35:12.741567Z 0 [ERROR] Aborting
2020-10-20T08:35:12.744010Z 0 [Note] Binlog end
2020-10-20T08:35:12.744082Z 0 [Note] Shutting down plugin 'CSV'
2020-10-20T08:35:12.744661Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2020-10-20T08:35:13.224175Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-10-20T08:35:13.225667Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 758 ...
2020-10-20T08:35:13.230695Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-10-20T08:35:13.230737Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-10-20T08:35:13.230744Z 0 [Note] InnoDB: Uses event mutexes
2020-10-20T08:35:13.230751Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-10-20T08:35:13.230757Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-10-20T08:35:13.230765Z 0 [Note] InnoDB: Using Linux native AIO
2020-10-20T08:35:13.231064Z 0 [Note] InnoDB: Number of pools: 1
2020-10-20T08:35:13.231190Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-10-20T08:35:13.232725Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-10-20T08:35:13.232769Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-10-20T08:35:13.232781Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-10-20T08:35:13.232788Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-10-20T08:35:13.232795Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-10-20T08:35:13.232799Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-10-20T08:35:13.232805Z 0 [ERROR] Failed to initialize builtin plugins.
2020-10-20T08:35:13.232808Z 0 [ERROR] Aborting
2020-10-20T08:35:13.234497Z 0 [Note] Binlog end
2020-10-20T08:35:13.234553Z 0 [Note] Shutting down plugin 'CSV'
2020-10-20T08:35:13.234968Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
Till now, I didn’t made any changes in any (configuration) files.
free -m
outputs:
total used free shared buff/cache available
Mem: 256 21 137 1 97 233
Swap: 0 0 0
Why isn’t MySQL starting?
asked Oct 20, 2020 at 7:39
Mine did the exact same thing and I have no idea still how to fix it. I resorted to just using SQLite3 rather than MySQL. If you can, try using MariaDB or something else in the meantime unless you can find a solution.
–
Check error log file for the mysql service. Default path is /var/log/mysql/error.log
–
Hello. Could you restart the server (sudo systemctl restart mysql
) and give the output of that command + journal -xe -u mysql
? The last command will narrow the output to mysql.
–
@MarcVanhoomissen I already posted that in my first post, didn’t I?
–
You have only 256MB of memory on your server. MySQL told you, about the reason: 2020-10-20T08:35:10.879879Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12 2020-10-20T08:35:10.879887Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
The solution maybe add swap space in your system.
–
As @mariaczi
found out, the problem is, that there isn’t enough RAM for MySQL to start.
I tried to add swap space, but without success. Maybe this is not possible on my virtual server.
I finally ended up with adding the following to /etc/my.cnf
:
[mysqld]
innodb_buffer_pool_size=100M
After that, I restarted the server and I was able to use MySQL.
source : https://askubuntu.com/questions/1285247/mysql-not-starting-after-installed-on-ubuntu-18-04-job-for-mysql-service-failed