0

I can't start mysql and when I run any type of start command, whether it be systemctl start mysql or service mysql start, I get the same error:

Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

And when I run systemctl status mysql.service I get this: https://hatebin.com/iefidgteub

Or if I run mysql I get ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) so I looked around, and I ran find / -type s to try and locate the mysqld.sock file but in the output, mysqld.sock wasn't one of the files it returned

Then, if I try running mysqld, I get https://hatebin.com/nyszqpalec

Jakaboii
  • 1
  • 3
  • How did you install MySQL? – Bert Aug 03 '20 at 12:14
  • It seems clear from your screen capture that `/var/lib/mysql-files` does not exist and does not contain the mysql files. In many cases the default location is `/var/lib/mysql`. Check whether they are already there, or do a `find` for `ibdata1`. If they already exist somewhere else, set the path in `/etc/my.cnf` using `datadir=/var/lib/mysql`. – tater Aug 03 '20 at 12:16
  • `/var/lib/mysql` does exist, but in `/etc/mysql/mariadb.conf.d/50-server.cnf`, `datadir=` is already set to `/var/lib/mysql` and in `/etc/mysql/mysql.conf.d/my.cnf` it's set to the same thing, though I did find out that in `/etc/mysql/my.cnf` one of the `!includedir` was set to `/etc/mysql/conf.d` instead of `/etc/mysql/mysql.conf.d` where all of those configuration files are, so I updated it and tried to start mysql but I still get the same error – Jakaboii Aug 03 '20 at 12:29
  • Config is either being ignored or set to `/var/lib/mysql-files` somewhere. If you want a practical fix and don't mind a hack, `mv /var/lib/mysql /var/lib/mysql-files`. Otherwise you need to sort through the config files that are being read. – tater Aug 03 '20 at 12:42
  • I did that, but still get the same error, what about the `mysqld.sock` file? Would that have anything to do with it? – Jakaboii Aug 03 '20 at 13:11
  • Still getting these errors: https://hatebin.com/hzwjoidukt https://hatebin.com/ogvmgozhnq Though when I run `mysqld` it doesn't output an error – Jakaboii Aug 03 '20 at 13:15
  • You have two different errors. First is starting mysql. Check that is running, e.g. `systemctl status mysql`, `ps -ef | grep mysql`. Second error is related to the socket. Check directory `/var/run/mysqld` exists and has correct ownership/permissions, and that mysqld is not trying to create the socket somewhere else. As a higher level comment your mysql seems hosed. Unless you actually have some data/settings worth keeping, I'd remove the lot and reinstall using a package manager. – tater Aug 03 '20 at 13:23
  • https://hatebin.com/rbrmkypchd is the output of `systemctl status mysql` and the `/var/run/mysqld` directory doesn't exist – Jakaboii Aug 03 '20 at 13:26
  • Also, reinstalling would be a bit of a pain considering I use Pterodactyl Panel, so I'd have to go through and set everything up again with the same credentials. So I hope there's another alternative – Jakaboii Aug 03 '20 at 13:51
  • Look in `mysqld.log` for further errors. If your configuration is hosed and you don't want to reinstall mysql, you will need to track down and fix each error one by one. Regarding the socket, you'll need to either create `/var/run/mysqld` with appropriate ownership and permissions, or set `socket=` option in your mysql config. – tater Aug 03 '20 at 13:55
  • Ok, for the socket issue, do I just create the `mysqld` folder? And then chmod with 777 permissions? And then when I start mysql after fixing other issues will it create the files by itself? – Jakaboii Aug 03 '20 at 13:57
  • I ran `find / -iname mysqld.log` (I don't know if that's the right command to find the `mysqld.log` file) and it returned nothing, then I ran `locate -i mysqld` and it didn't return a log file – Jakaboii Aug 03 '20 at 14:00
  • When creating the `/var/run/mysqld` folder, whenever I assign permissions the folder just deletes itself – Jakaboii Aug 03 '20 at 22:45

1 Answers1

0

Your error is in the log that you posted:

mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2020-08-03T11:17:14.960692Z 0 [ERROR] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files

Ensure the directory /var/lib/mysql-files exists and MySQL should start.

Bert
  • 2,863
  • 12
  • 13
  • `/var/lib/mysql-files` doesn't exist, though `/var/lib/mysql` does – Jakaboii Aug 03 '20 at 12:30
  • Could you post TEXT results of ls from the OS command prompt when in /var/lib/mysql ? – Wilson Hauck Aug 03 '20 at 17:15
  • Sure, I changed it to `mysql-files` as I was asked to in a comment above, here's the output: https://hatebin.com/hjocqqtlne – Jakaboii Aug 03 '20 at 20:13
  • Your prompt was - root@ubuntu:/var/lib/mysql-files# when you requested the ls. Could you get to a prompt of /var/lib/mysql and request ls? Then post the results, please. I suspect mysql-files is an accidental folder that was created in the past. We do not normally see a folder named mysql-files in a typical install. – Wilson Hauck Sep 19 '20 at 14:52