Question

MySQL service unable to start...

Hi,

I’m getting an “Error establishing a database connection” in WordPress, and on further inspection it looks like the MySQL service isnt running.

When I try and run sudo service mysql start, I get:

Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.

If I run systemctl status mysql.service I get:

Loaded: loaded (/etc/init.d/mysql)
   Active: failed (Result: exit-code) since Mon 2019-06-03 09:00:20 UTC; 18s ago
  Process: 936 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

running sudo journalctl -xn gives me:

-- Logs begin at Mon 2019-06-03 08:58:05 UTC, end at Mon 2019-06-03 09:09:21 UTC. --
Jun 03 09:09:01 roofingsheetsbyrhino cron[509]: Authentication token is no longer valid; new one required
Jun 03 09:09:01 roofingsheetsbyrhino cron[509]: Authentication token is no longer valid; new one required
Jun 03 09:09:09 roofingsheetsbyrhino sshd[991]: Invalid user share123 from 106.12.24.108
Jun 03 09:09:09 roofingsheetsbyrhino sshd[991]: input_userauth_request: invalid user share123 [preauth]
Jun 03 09:09:09 roofingsheetsbyrhino sshd[991]: pam_unix(sshd:auth): check pass; user unknown
Jun 03 09:09:09 roofingsheetsbyrhino sshd[991]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=106.12.24.108
Jun 03 09:09:10 roofingsheetsbyrhino sshd[991]: Failed password for invalid user share123 from 106.12.24.108 port 55360 ssh2
Jun 03 09:09:11 roofingsheetsbyrhino sshd[991]: Received disconnect from 106.12.24.108: 11: Bye Bye [preauth]
Jun 03 09:09:21 roofingsheetsbyrhino sudo[993]: tom : TTY=pts/0 ; PWD=/var/www ; USER=root ; COMMAND=/bin/journalctl -xn
Jun 03 09:09:21 roofingsheetsbyrhino sudo[993]: pam_unix(sudo:session): session opened for user root by tom(uid=0)

I’m really not sure what the issue is here, or how this has come about - any advice as to what I should do next would be hugely appreciated!

Thanks!

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Embarrassingly, I just realised that the issue here was my backup plugin had piled up loads of backups rather than deleting the old ones… So the droplet had run out of disk space which was causing the issues.

So I’ve fixed the problem! Thanks for your help asciant!

here is my /etc/mysql/mysql.conf.d/mysqld.cnf file replace it with yours and make chmod 777 it should work.

#
# 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
:i
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        = 100
#table_open_cache       = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit	= 1M
query_cache_size        = 16M
#
# * 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".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem


all mysqld --help gives me is:

mysqld  Ver 10.0.27-MariaDB-0+deb8u1 for debian-linux-gnu on x86_64 ((Debian))
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Starts the MariaDB database server.

Usage: mysqld [OPTIONS]

For more help options (several pages), use mysqld --verbose --help.

Is this cause I am using MariaDB? Are the logs in a different place?

Thanks, all I see with sudo vi /var/log/mysql.log is:

~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/var/log/mysql.log" 0L, 0C

I’m presuming this means an empty file?

I’m not sure if I’m being really dumb or that log file is just empty…

sudo less /var/log/mysql.log is just displaying skipping... over and over again…

Thanks, I’ll check those logs and report back.

running sudo systemctl start mysqld gives me:

Failed to start mysqld.service: Unit mysqld.service failed to load: No such file or directory.

That log doesn’t appear to have any MySQL info in it (which is probably stating the obvious). I believe the default log location is /var/log/mysql.log try looking in there to see if you can get any more information. If it’s not in that location, usually the log_error configuration variable will tell you where it is.

Just quickly though, what happens when you run sudo systemctl start mysqld?