MySQL not running

Hello,

I'm trying to fix a Linode I've been assigned to work on. It's hosting a WordPress site and it no longer connects to the database. I'm pretty good with Linux and the shell but this one has me stumped. I have another Linode webserver that is running and I'm comparing the two to troubleshoot.

There is no mysqld.sock or mysqld.pid. Apache is running. I've tried invoking the mysqladmin, mysqld, and mysql commands but they don't seem to work

Can someone point me to where I might begin to debug this situation?

Thanks.

8 Replies

What errors do mysqladmin, etc return?

What does systemctrl status mysqld return (or the init script for your distro)?

Here's one error. When trying to get into the mysql shell. At least it asks for a password. I'll post others.

root@ubuntu:~# mysql -u root -p

Enter password:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

It seems like MySQL might not be running at all. I would second derfy's recommendation–a good next step is to check on the status of the process:

sudo systemctl status mysql -l

This can also turn up some relevant logs:

sudo journalctl -u mysql --no-pager | tail -20

You should also check if your disk is full; this is a common reason for why MySQL won't start:

df -i

df -h

I'm getting command not found.

sudo: systemctl: command not found

sudo: journalctl: command not found

I've got 2 linodes, one works. I get the above returned on both. Sounds like maybe an environment issue maybe? It's not including another directory in the search for the command?

I used both my local terminal and the web based one through the Linode control panel.

The df -i and df -h commands do work and there's plenty of disk space.

Try service mysql status – sounds like you're not on systemd

OK…I get "mysql stop/waiting"

Looks like progress.

I believe I'm dealing with a CHOWN issue. I see that by comparing the Linode that is working to the one that isn't. For example in the working Linode in /var/run/mysqld the ownership is mysql:root and it contains the pid and sock files like this.

-rw-rw–-- 1 mysql mysql 5 Mar 28 16:58 mysqld.pid

srwxrwxrwx 1 mysql mysql 0 Mar 28 16:58 mysqld.sock

In the Linode not working there are no such files. The ownership was root:root.

Somehow it got changed. I should verify ownership of the related and dependent directories and files.

I resolved this issue. It was a chown error. Chown was run on directories that it should not have been run against.

Speciifically the directory /var/lib/mysql and all it's contents had ownership set to root:root. I set it all to mysql:mysql and that fixed it.

Thanks to the suggestions I got different views on this problem and finally honed in on the solution. I appreciate the support.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct